Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jLhwZ-0000b4-2Q for pgsql-performance@arkaria.postgresql.org; Tue, 07 Apr 2020 06:42:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jLhwX-0003UJ-VD for pgsql-performance@arkaria.postgresql.org; Tue, 07 Apr 2020 06:42:41 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jLhwX-0003Sy-Nh for pgsql-performance@lists.postgresql.org; Tue, 07 Apr 2020 06:42:41 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jLhwU-00081X-AG for pgsql-performance@postgresql.org; Tue, 07 Apr 2020 06:42:40 +0000 Received: by mail-wr1-x443.google.com with SMTP id j17so2438251wru.13 for ; Mon, 06 Apr 2020 23:42:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=f7dRdiX7fZWGNnUTRfux6+jWdgqCw3ZZOwHhdgF4kQg=; b=M7H31NEYcR5mis4GCd8vTpvdtqkljePkRN4aCGEJc9uJmHDUcfeZkzjyjn9ZxWkid9 cLzSAmdYUUzKHoNohJAczDCUcDAgKraf/rObc2+ab8RjIpGOQpkXohI2IyZaiZ8+zP2K 165l7gFp86Mp81YcTnKcd2JImMPvwvFlo1jHKweqGeiVUnGvX4ag7oqFJx2xjkc65uv/ U1QP1/9tIMzjVooOH0NwEaYzPiWWfs9X58Nn4AYKhrLPG+YmWIAqCxnGMN8B4wrCfFIO uTCDCqPc/MIeLFQavshQ0geieYhxqZDJU7mZ2+iOVvSebsvDbB9qw74vfDA7vqxWyK0u K/zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=f7dRdiX7fZWGNnUTRfux6+jWdgqCw3ZZOwHhdgF4kQg=; b=EFe70a9+KOChcUuhEspgZjWM2rm0nMxLSA/B6kkMcGACuWXsJSQzM9gnpI0DccWUTc PbaJ0av1VL7wzRUnhLW1vJp3dPN5BDLEG0Ub29qvPdjB9Zq/AdQbKQIidi15E5r4IDPJ az5lCmy0S05dYlCb1DVMaWSy5aNrIPnAl6i4f4bHeN03HKSy/fEtg57AhC2isFhX+8O6 xY8SEdlua91Q46LPL1diNpU/bXwlMxh8hIPkfSLU0YWoG9kM+/SUxrEWdlxmZ6fEn2qp kT50aLlsQjAkUpBMS7Ek6S8Ei4hG/Oziclgb2su70hargGhHLMFi9pxykD0+D0NqWvvH ra1Q== X-Gm-Message-State: AGi0PubyuRt8KQh4Uq9GFbgq/ntxAwSBcNM/iuKXLxwB/ri2Q/uyIZui cGrmnzeF3okrRGoA/QXHU09Q/qxovBA= X-Google-Smtp-Source: APiQypIOpLpdN/SgyAvnImKnWRGsEqnWRGx9XTCYonzY7+Rdl8mB4hfQF+p07Gmy5c+pegMlCgCIvQ== X-Received: by 2002:adf:fa85:: with SMTP id h5mr956660wrr.63.1586241756611; Mon, 06 Apr 2020 23:42:36 -0700 (PDT) Received: from dynamic-eo9lc8043u2qr9u6l-pd01.res.v6.highway.a1.net (dynamic-eo9lc8043u2qr9u6l-pd01.res.v6.highway.a1.net. [2001:871:60:9a62:6597:76d3:1e4c:440d]) by smtp.gmail.com with ESMTPSA id y33sm14959131wrd.84.2020.04.06.23.42.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Apr 2020 23:42:36 -0700 (PDT) Message-ID: <1b2a5b7c6c3a5610be90944ab43c3b53a4def335.camel@cybertec.at> Subject: Re: Postgres not using index on views From: Laurenz Albe To: Rick Vincent , "pgsql-performance@postgresql.org" Cc: Manoj Kumar , Herve Aubert Date: Tue, 07 Apr 2020 08:42:35 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.5 (3.32.5-1.fc30) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, 2020-04-06 at 14:19 +0000, Rick Vincent wrote: > I am seeing a performance problem with postgresql v 11.7 on views, and I am wondering if > anyone can tell me why or has any suggestion. Your account is somewhat confused - too many questions rolled into one rant, I would say. There are two points that may clear up the case: - If you have no WHERE clause, a sequential scan of the table is usually the best way to do it. The exception is an index only scan if the index contains all that is required, but in PostgreSQL you need a recently VACUUMed table for that. - The expensive part in your view is the "extractValueJS" function. Try to tune that for better performance. If any of your problems are not explained by that, please say so. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com