From bill@math.uchicago.edu Mon Jun 28 03:26:17 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 947F7D1B23C for ; Mon, 28 Jun 2004 00:26:17 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 21027-01 for ; Mon, 28 Jun 2004 03:26:15 +0000 (GMT) Received: from bill.fefferman.org (dsl081-139-018.chi1.dsl.speakeasy.net [64.81.139.18]) by svr1.postgresql.org (Postfix) with ESMTP id 5D823D1B233 for ; Mon, 28 Jun 2004 00:26:13 -0300 (ADT) Received: from billnotebook ([192.168.1.21]) by bill.fefferman.org with Microsoft SMTPSVC(6.0.3790.0); Sun, 27 Jun 2004 22:26:14 -0500 From: "Bill" To: Subject: Query performance Date: Sun, 27 Jun 2004 22:26:19 -0500 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0001_01C45C95.C4BA4240" X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 Thread-Index: AcRcv5muswl0fDZXQhqcyfGmT78eHw== Message-ID: X-OriginalArrivalTime: 28 Jun 2004 03:26:14.0421 (UTC) FILETIME=[AA9E0C50:01C45CBF] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.5 tagged_above=0.0 required=5.0 tests=HTML_40_50, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200406/268 X-Sequence-Number: 7326 This is a multi-part message in MIME format. ------=_NextPart_000_0001_01C45C95.C4BA4240 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Actually, I have some queries that are slow, however I was wondering if you could help me write a query that is rather simple, but I, as a true database novice, can't seem to conjure. So we have stocks, as I have previously said, and I have a huge table which contains all of the opening and closing prices of some stocks from each day. What I like to do, in English, for each stock in each day is find a ratio: abs(closing-opening)/opening. Then I would like to average all of the ratios of each day of each individual stock together to find a final ratio for each stock, then I would like to find the highest average, to find the best performing stock. So what query can I use, and (as is appropriate for this group), how can it be optimized to run the fastest? ------=_NextPart_000_0001_01C45C95.C4BA4240 Content-Type: text/html; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable

Actually, I have some queries that are slow, however I was wondering if you could help me write a query that is rather simple, but I, as a true database novice, can't seem to conjure.  So we have stocks, as I have previously said, and I have a h= uge table which contains all of the opening and closing prices of some stocks from ea= ch day.  What I like to do, in English, for each stock in each day is fin= d a ratio: abs(closing-opening)/opening.  Then I would like to average all= of the ratios of each day of each individual stock together to find a final ratio = for each stock, then I would like to find the highest average, to find the best performing stock.  So what query can I use, and (as is appropriate for= this group), how can it be optimized to run the fastest?

 

------=_NextPart_000_0001_01C45C95.C4BA4240-- From mischa_sandberg@telus.net Mon Jun 28 05:44:11 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C13F7D1B248 for ; Mon, 28 Jun 2004 02:44:11 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 62250-04 for ; Mon, 28 Jun 2004 05:44:09 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 127C0D1B1F8 for ; Mon, 28 Jun 2004 02:44:07 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i5S5i6QC077021 for ; Mon, 28 Jun 2004 05:44:06 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i5S5Nr58069913 for pgsql-performance@postgresql.org; Mon, 28 Jun 2004 05:23:53 GMT From: "Mischa Sandberg" X-Newsgroups: comp.databases.postgresql.performance References: Subject: Re: Query performance Lines: 156 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_004C_01C45C95.6EC8EA80" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Message-ID: Date: Mon, 28 Jun 2004 05:23:53 GMT To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.8 tagged_above=0.0 required=5.0 tests=HTML_40_50, HTML_MESSAGE, PRIORITY_NO_NAME, WEIRD_QUOTING X-Spam-Level: * X-Archive-Number: 200406/332 X-Sequence-Number: 7390 This is a multi-part message in MIME format. ------=_NextPart_000_004C_01C45C95.6EC8EA80 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Usually, when you post a request like this, you should provide something a = little more concrete (the CREATE TABLE statement for that table, with=20 Since you didn't, I'll posit something that sounds like what you're using, = and take a stab at your problem. TABLE Prices ( stock VARCHAR(9) ,asof DATE, ,opening MONEY ,closing MONEY ,PRIMARY KEY (stock, asof) ) SELECT stock, AVG((closing-opening)/opening) as ratio FROM Prices=20 GROUP BY stock ORDER BY ratio DESC LIMIT 10; -- top 10 best-performing stocks. ""Bill"" wrote in message news:BILLSA1XvpFVjCRGryW= 00000002@bill.fefferman.org... Actually, I have some queries that are slow, however I was wondering if y= ou could help me write a query that is rather simple, but I, as a true data= base novice, can't seem to conjure. So we have stocks, as I have previousl= y said, and I have a huge table which contains all of the opening and closi= ng prices of some stocks from each day. What I like to do, in English, for= each stock in each day is find a ratio: abs(closing-opening)/opening. The= n I would like to average all of the ratios of each day of each individual = stock together to find a final ratio for each stock, then I would like to f= ind the highest average, to find the best performing stock. So what query = can I use, and (as is appropriate for this group), how can it be optimized = to run the fastest? =20=20=20 ------=_NextPart_000_004C_01C45C95.6EC8EA80 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Usually, when you post a request like this, you should = provide=20 something a little more concrete (the CREATE TABLE statement for that table= ,=20 with
Since you didn't, I'll posit something that sounds like= what=20 you're using, and take a stab at your problem.
 
TABLE Prices (
    stock   =20 VARCHAR(9)
    ,asof    =20     DATE,
    ,opening   MONEY
    ,closing   =20 MONEY
    ,PRIMARY KEY (stock, asof)
    )
 
SELECT    stock, AVG((closing-opening)/o= pening)=20 as ratio
FROM    Prices
GROUP BY stock
ORDER BY ratio DESC LIMIT 10;    -- top = 10=20 best-performing stocks.
 
""Bill"" <bill@math.uchicago.edu> wrote= in=20 message news:BILLSA1Xv= pFVjCRGryW00000002@bill.fefferman.org...

Actually, I have so= me=20 queries that are slow, however I was wondering if you could help me write= a=20 query that is rather simple, but I, as a true database novice, can't seem= to=20 conjure.  So we have stocks, as I have previously said, and I have a= huge=20 table which contains all of the opening and closing prices of some stocks= from=20 each day.  What I like to do, in English, for each stock in each day= is=20 find a ratio: abs(closing-opening)/opening.  Then I would like to av= erage=20 all of the ratios of each day of each individual stock together to find a= =20 final ratio for each stock, then I would like to find the highest average= , to=20 find the best performing stock.  So what query can I use, and (as is= =20 appropriate for this group), how can it be optimized to run the=20 fastest?

 

------=_NextPart_000_004C_01C45C95.6EC8EA80-- From dev@archonet.com Mon Jun 28 09:14:15 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0120DD1B347 for ; Mon, 28 Jun 2004 06:14:15 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 51185-02 for ; Mon, 28 Jun 2004 09:14:14 +0000 (GMT) Received: from anchor-post-32.mail.demon.net (anchor-post-32.mail.demon.net [194.217.242.90]) by svr1.postgresql.org (Postfix) with ESMTP id C0558D1B2BD for ; Mon, 28 Jun 2004 06:14:11 -0300 (ADT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-32.mail.demon.net with esmtp (Exim 3.35 #1) id 1BesDN-0007o0-0W; Mon, 28 Jun 2004 10:14:13 +0100 Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 6DB0716C93; Mon, 28 Jun 2004 10:14:12 +0100 (BST) Message-ID: <40DFE163.8000107@archonet.com> Date: Mon, 28 Jun 2004 10:14:11 +0100 From: Richard Huxton User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Bill Cc: pgsql-performance@postgresql.org Subject: Re: Query performance References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200406/274 X-Sequence-Number: 7332 Bill wrote: > Actually, I have some queries that are slow, however I was wondering if you > could help me write a query that is rather simple, but I, as a true database > novice, can't seem to conjure. So we have stocks, as I have previously > said, and I have a huge table which contains all of the opening and closing > prices of some stocks from each day. Schemas, Bill - show us your table definitions so people can see exactly where they stand. -- Richard Huxton Archonet Ltd From bill@math.uchicago.edu Mon Jun 28 17:02:44 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 44399D1B1A9 for ; Mon, 28 Jun 2004 14:02:44 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 85498-05 for ; Mon, 28 Jun 2004 17:02:39 +0000 (GMT) Received: from math.uchicago.edu (math.uchicago.edu [128.135.72.38]) by svr1.postgresql.org (Postfix) with ESMTP id 6ABCBD1B174 for ; Mon, 28 Jun 2004 14:02:36 -0300 (ADT) Received: from billnotebook (wireless-199-208.uchicago.edu [128.135.199.208]) by math.uchicago.edu (8.12.10/8.12.10) with ESMTP id i5SH2YfL013269 for ; Mon, 28 Jun 2004 12:02:36 -0500 Message-Id: <200406281702.i5SH2YfL013269@math.uchicago.edu> From: "Bill" To: Subject: Re: Query performance Date: Mon, 28 Jun 2004 12:02:40 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.5510 In-Reply-To: <40DFE163.8000107@archonet.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 Thread-Index: AcRc8SMpS+jFDE1lQ1KaBvEuUe1v6AAQEUUg X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200406/276 X-Sequence-Number: 7334 Ok....so here lies the output of oclh (i.e "\d oclh") Table "public.oclh" Column | Type | Modifiers --------+-----------------------+------------------------------- symbol | character varying(10) | not null default '' date | date | not null default '0001-01-01' open | numeric(12,2) | not null default '0.00' close | numeric(12,2) | not null default '0.00' low | numeric(12,2) | not null default '0.00' high | numeric(12,2) | not null default '0.00' Indexes: symbol_2_oclh_index btree (symbol, date), symbol_oclh_index btree (symbol, date) -----Original Message----- From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Richard Huxton Sent: Monday, June 28, 2004 4:14 AM To: Bill Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Query performance Bill wrote: > Actually, I have some queries that are slow, however I was wondering if you > could help me write a query that is rather simple, but I, as a true database > novice, can't seem to conjure. So we have stocks, as I have previously > said, and I have a huge table which contains all of the opening and closing > prices of some stocks from each day. Schemas, Bill - show us your table definitions so people can see exactly where they stand. -- Richard Huxton Archonet Ltd ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster From dev@archonet.com Tue Jun 29 08:37:59 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EEC9FD1B211 for ; Tue, 29 Jun 2004 05:37:59 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 02892-04 for ; Tue, 29 Jun 2004 08:37:53 +0000 (GMT) Received: from anchor-post-30.mail.demon.net (anchor-post-30.mail.demon.net [194.217.242.88]) by svr1.postgresql.org (Postfix) with ESMTP id CB929D1B258 for ; Tue, 29 Jun 2004 05:37:50 -0300 (ADT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-30.mail.demon.net with esmtp (Exim 3.35 #1) id 1BfE7j-000PTe-0U; Tue, 29 Jun 2004 09:37:51 +0100 Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 09E5316C60; Tue, 29 Jun 2004 09:37:50 +0100 (BST) Message-ID: <40E12A5D.70007@archonet.com> Date: Tue, 29 Jun 2004 09:37:49 +0100 From: Richard Huxton User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Bill Cc: pgsql-performance@postgresql.org Subject: Re: Query performance References: <200406281702.i5SH2YfL013269@math.uchicago.edu> In-Reply-To: <200406281702.i5SH2YfL013269@math.uchicago.edu> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200406/287 X-Sequence-Number: 7345 Bill wrote: > Ok....so here lies the output of oclh (i.e "\d oclh") > > Table "public.oclh" > Column | Type | Modifiers > --------+-----------------------+------------------------------- > symbol | character varying(10) | not null default '' > date | date | not null default '0001-01-01' > open | numeric(12,2) | not null default '0.00' > close | numeric(12,2) | not null default '0.00' > low | numeric(12,2) | not null default '0.00' > high | numeric(12,2) | not null default '0.00' > Indexes: symbol_2_oclh_index btree (symbol, date), > symbol_oclh_index btree (symbol, date) Well, I'm not sure why the two indexes on the same columns, and I'm not sure it makes sense to have defaults for _any_ of the columns there. So - you want: 1. ratio = abs(closing-opening)/opening 2. average = all the ratios of each day of each stock 3. Highest average Well, I don't know what you mean by #2, but #1 is just: SELECT symbol, "date", abs(close - open)/open AS ratio FROM oclh GROUP BY symbol, date; I'd probably fill in a summary table with this and use that as the basis for your further queries. Presumably from "yesterday" back, the ratios/averages won't change. -- Richard Huxton Archonet Ltd From bill@math.uchicago.edu Tue Jun 29 17:33:54 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 64188D1B1B4 for ; Tue, 29 Jun 2004 14:33:54 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 09655-04 for ; Tue, 29 Jun 2004 17:33:48 +0000 (GMT) Received: from math.uchicago.edu (math.uchicago.edu [128.135.72.38]) by svr1.postgresql.org (Postfix) with ESMTP id 33A6DD1B1AA for ; Tue, 29 Jun 2004 14:33:46 -0300 (ADT) Received: from billnotebook (wireless-197-223.uchicago.edu [128.135.197.223]) by math.uchicago.edu (8.12.10/8.12.10) with ESMTP id i5THXkfL031311 for ; Tue, 29 Jun 2004 12:33:46 -0500 Message-Id: <200406291733.i5THXkfL031311@math.uchicago.edu> From: "Bill" To: Subject: Re: Query performance Date: Tue, 29 Jun 2004 12:33:51 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 In-Reply-To: <40E12A5D.70007@archonet.com> Thread-Index: AcRdtTtifCTAR38tQAerxJIonFzvKQASJpwg X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200406/311 X-Sequence-Number: 7369 Ok, thanks. So let me explain the query number 2 as this is the more difficult to write. So I have a list of stocks, this table contains the price of all of the stocks at the open and close date. Ok, now we have a ratio from query (1) that returns at least a very rough index of the daily performance of a given stock, with each ratio representing the stock's performance in one day. Now we need to average this with the same stock's ratio every day, to get a total average for each stock contained in the database. Now I would simply like to find a ratio like this that represents the average of every stock in the table and simply find the greatest ratio. Sorry about the lousy explanation before, is this a bit better? Here is an example if needed. Say we have a stock by the name of YYY I know, due to query 1 that stock YYY has a abs(close-open)/open price ratio of for example, 1.3 on Dec 1 and (for simplicity let's say we only have two dates) and Dec 2 the ratio for YYY is 1.5. So the query averages and gets 1.4. Now it needs to do this for all of the stocks in the table and sort by increasing ratio. Thanks. -----Original Message----- From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Richard Huxton Sent: Tuesday, June 29, 2004 3:38 AM To: Bill Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Query performance Bill wrote: > Ok....so here lies the output of oclh (i.e "\d oclh") > > Table "public.oclh" > Column | Type | Modifiers > --------+-----------------------+------------------------------- > symbol | character varying(10) | not null default '' > date | date | not null default '0001-01-01' > open | numeric(12,2) | not null default '0.00' > close | numeric(12,2) | not null default '0.00' > low | numeric(12,2) | not null default '0.00' > high | numeric(12,2) | not null default '0.00' > Indexes: symbol_2_oclh_index btree (symbol, date), > symbol_oclh_index btree (symbol, date) Well, I'm not sure why the two indexes on the same columns, and I'm not sure it makes sense to have defaults for _any_ of the columns there. So - you want: 1. ratio = abs(closing-opening)/opening 2. average = all the ratios of each day of each stock 3. Highest average Well, I don't know what you mean by #2, but #1 is just: SELECT symbol, "date", abs(close - open)/open AS ratio FROM oclh GROUP BY symbol, date; I'd probably fill in a summary table with this and use that as the basis for your further queries. Presumably from "yesterday" back, the ratios/averages won't change. -- Richard Huxton Archonet Ltd ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org From dev@archonet.com Tue Jun 29 19:03:37 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9E252D1B182 for ; Tue, 29 Jun 2004 16:03:37 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 55866-03 for ; Tue, 29 Jun 2004 19:03:30 +0000 (GMT) Received: from anchor-post-37.mail.demon.net (anchor-post-36.mail.demon.net [194.217.242.86]) by svr1.postgresql.org (Postfix) with ESMTP id 643CDD1B258 for ; Tue, 29 Jun 2004 16:03:27 -0300 (ADT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-37.mail.demon.net with esmtp (Exim 3.35 #1) id 1BfNt9-0007ZU-0b; Tue, 29 Jun 2004 20:03:27 +0100 Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id C4ABB16520; Tue, 29 Jun 2004 20:03:26 +0100 (BST) Message-ID: <40E1BCFD.9090401@archonet.com> Date: Tue, 29 Jun 2004 20:03:25 +0100 From: Richard Huxton User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Bill Cc: pgsql-performance@postgresql.org Subject: Re: Query performance References: <200406291733.i5THXkfL031311@math.uchicago.edu> In-Reply-To: <200406291733.i5THXkfL031311@math.uchicago.edu> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200406/312 X-Sequence-Number: 7370 Bill wrote: > Ok, thanks. So let me explain the query number 2 as this is the more > difficult to write. So I have a list of stocks, this table contains the > price of all of the stocks at the open and close date. Ok, now we have a > ratio from query (1) that returns at least a very rough index of the daily > performance of a given stock, with each ratio representing the stock's > performance in one day. Now we need to average this with the same stock's > ratio every day, to get a total average for each stock contained in the > database. Now I would simply like to find a ratio like this that represents > the average of every stock in the table and simply find the greatest ratio. > Sorry about the lousy explanation before, is this a bit better? > > Here is an example if needed. > > Say we have a stock by the name of YYY > > I know, due to query 1 that stock YYY has a abs(close-open)/open price ratio > of for example, 1.3 on Dec 1 and (for simplicity let's say we only have two > dates) and Dec 2 the ratio for YYY is 1.5. So the query averages and gets > 1.4. Now it needs to do this for all of the stocks in the table and sort by > increasing ratio. Well, the simplest would be something like: CREATE VIEW my_ratios AS SELECT ...(select details we used for #1 previously) Query #1 then becomes: SELECT * FROM my_ratios; Then you could do: SELECT symbol, avg(ratio) as ratio_avg FROM my_ratios GROUP BY symbol ORDER BY avg(ratio) ; Now, in practice, I'd probably create a symbol_ratio table and fill that one day at a time. Then #2,#3 would be easier. -- Richard Huxton Archonet Ltd From bruno@wolff.to Tue Jun 29 19:45:02 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5C07ED1B1D2 for ; Tue, 29 Jun 2004 16:45:02 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 77015-05 for ; Tue, 29 Jun 2004 19:44:57 +0000 (GMT) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id D04C5D1B179 for ; Tue, 29 Jun 2004 16:44:54 -0300 (ADT) Received: (qmail 1689 invoked by uid 500); 29 Jun 2004 19:51:30 -0000 Date: Tue, 29 Jun 2004 14:51:30 -0500 From: Bruno Wolff III To: Bill Cc: pgsql-performance@postgresql.org Subject: Re: Query performance Message-ID: <20040629195130.GA1513@wolff.to> Mail-Followup-To: Bill , pgsql-performance@postgresql.org References: <40E12A5D.70007@archonet.com> <200406291733.i5THXkfL031311@math.uchicago.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200406291733.i5THXkfL031311@math.uchicago.edu> User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200406/314 X-Sequence-Number: 7372 On Tue, Jun 29, 2004 at 12:33:51 -0500, Bill wrote: > Ok, thanks. So let me explain the query number 2 as this is the more > difficult to write. So I have a list of stocks, this table contains the > price of all of the stocks at the open and close date. Ok, now we have a > ratio from query (1) that returns at least a very rough index of the daily > performance of a given stock, with each ratio representing the stock's > performance in one day. Now we need to average this with the same stock's > ratio every day, to get a total average for each stock contained in the > database. Now I would simply like to find a ratio like this that represents > the average of every stock in the table and simply find the greatest ratio. > Sorry about the lousy explanation before, is this a bit better? You can do something like: SELECT symbol, avg((open-close)/open) GROUP BY symbol ORDER BY avg((open-close)/open) DESC LIMIT 1; If you aren't interested in the variance of the daily change, it seems like you would be best off using the opening price for the first day you have recorded for the stock and the closing price on the last day and looking at the relative change. From bill@math.uchicago.edu Wed Jun 30 13:46:57 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 930D6D1B184 for ; Wed, 30 Jun 2004 10:46:57 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 71125-05 for ; Wed, 30 Jun 2004 13:46:56 +0000 (GMT) Received: from math.uchicago.edu (math.uchicago.edu [128.135.72.38]) by svr1.postgresql.org (Postfix) with ESMTP id 7611FD1B172 for ; Wed, 30 Jun 2004 10:46:51 -0300 (ADT) Received: from billnotebook (wireless-197-223.uchicago.edu [128.135.197.223]) by math.uchicago.edu (8.12.10/8.12.10) with ESMTP id i5UDktfL013134 for ; Wed, 30 Jun 2004 08:46:55 -0500 Message-Id: <200406301346.i5UDktfL013134@math.uchicago.edu> From: "Bill" To: Subject: Re: Query performance Date: Wed, 30 Jun 2004 08:47:03 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.5510 In-Reply-To: <20040629195130.GA1513@wolff.to> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 Thread-Index: AcReEY+bwr8Aj6a5SVG7hH5fF/GZ0QAlvmYg X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200406/322 X-Sequence-Number: 7380 Thanks this query works for what I want. So here is an output of the explain analyze: QUERY PLAN ---------------------------------------------------------------------------- ------------------------------------------------------------------------ Limit (cost=2421582.59..2421582.65 rows=25 width=29) (actual time=1985800.32..1985800.44 rows=25 loops=1) -> Sort (cost=2421582.59..2424251.12 rows=1067414 width=29) (actual time=1985800.31..1985800.35 rows=26 loops=1) Sort Key: avg(((open - "close") / (open + 1::numeric))) -> Aggregate (cost=2200163.04..2280219.09 rows=1067414 width=29) (actual time=910291.94..1984972.93 rows=22362 loops=1) -> Group (cost=2200163.04..2253533.74 rows=10674140 width=29) (actual time=910085.96..1105064.28 rows=10674140 loops=1) -> Sort (cost=2200163.04..2226848.39 rows=10674140 width=29) (actual time=910085.93..988909.94 rows=10674140 loops=1) Sort Key: symbol -> Seq Scan on oclh (cost=0.00..228404.40 rows=10674140 width=29) (actual time=20.00..137720.61 rows=10674140 loops=1) Total runtime: 1986748.44 msec (9 rows) Can I get any better performance? Thanks. -----Original Message----- From: Bruno Wolff III [mailto:bruno@wolff.to] Sent: Tuesday, June 29, 2004 2:52 PM To: Bill Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Query performance On Tue, Jun 29, 2004 at 12:33:51 -0500, Bill wrote: > Ok, thanks. So let me explain the query number 2 as this is the more > difficult to write. So I have a list of stocks, this table contains the > price of all of the stocks at the open and close date. Ok, now we have a > ratio from query (1) that returns at least a very rough index of the daily > performance of a given stock, with each ratio representing the stock's > performance in one day. Now we need to average this with the same stock's > ratio every day, to get a total average for each stock contained in the > database. Now I would simply like to find a ratio like this that represents > the average of every stock in the table and simply find the greatest ratio. > Sorry about the lousy explanation before, is this a bit better? You can do something like: SELECT symbol, avg((open-close)/open) GROUP BY symbol ORDER BY avg((open-close)/open) DESC LIMIT 1; If you aren't interested in the variance of the daily change, it seems like you would be best off using the opening price for the first day you have recorded for the stock and the closing price on the last day and looking at the relative change. From pg@rbt.ca Wed Jun 30 14:27:30 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7F6CED1B26E for ; Wed, 30 Jun 2004 11:27:30 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 95765-02 for ; Wed, 30 Jun 2004 14:27:28 +0000 (GMT) Received: from tht.net (vista.tht.net [216.126.88.2]) by svr1.postgresql.org (Postfix) with ESMTP id CCF6DD1B252 for ; Wed, 30 Jun 2004 11:27:21 -0300 (ADT) Received: from [134.22.68.4] (dyn-68-4.tor.dsl.tht.net [134.22.68.4]) by tht.net (Postfix) with ESMTP id 0646076AAA; Wed, 30 Jun 2004 10:27:28 -0400 (EDT) Subject: Re: Query performance From: Rod Taylor To: Bill Cc: Postgresql Performance In-Reply-To: <200406301346.i5UDktfL013134@math.uchicago.edu> References: <200406301346.i5UDktfL013134@math.uchicago.edu> Content-Type: text/plain Message-Id: <1088605644.12340.10.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Wed, 30 Jun 2004 10:27:25 -0400 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200406/323 X-Sequence-Number: 7381 > Can I get any better performance? You can try bumping your sort memory way up (for this query only). Another method would be to cluster the table by the symbol column (eliminates the expensive sort). If you could run a very simple calculation against open & close numbers to eliminate a majority of symbols early, that would be useful as well. From dmota@nexen.com.br Fri Aug 20 23:59:04 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1F4725E40BB for ; Fri, 20 Aug 2004 20:59:04 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 39943-06 for ; Fri, 20 Aug 2004 23:59:00 +0000 (GMT) Received: from hm171.locaweb.com.br (hm171.locaweb.com.br [200.234.203.7]) by svr1.postgresql.org (Postfix) with SMTP id D08705E46D1 for ; Fri, 20 Aug 2004 20:58:56 -0300 (ADT) Received: (qmail 66197 invoked by uid 0); 20 Aug 2004 23:58:30 -0000 Received: from unknown (10.1.10.141) by hm171.locaweb.com.br with QMTP; 20 Aug 2004 23:58:30 -0000 Received: (qmail 11196 invoked from network); 20 Aug 2004 23:58:56 -0000 Received: from unknown (HELO xws08) (dmota@nexen.com.br@201.9.66.167) by hm141.locaweb.com.br with SMTP; 20 Aug 2004 23:58:56 -0000 Reply-To: From: "Danilo Mota" To: Subject: Query Performance Date: Fri, 20 Aug 2004 21:03:54 -0300 Organization: Nexen Tecnologia Message-ID: <000001c48712$599737a0$8afea8c0@nexen.lan> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0001_01C486F9.3449FFA0" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2616 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=HTML_70_80, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200408/310 X-Sequence-Number: 7946 This is a multi-part message in MIME format. ------=_NextPart_000_0001_01C486F9.3449FFA0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi all, the following query is working well without the AND on WHERE clause, so I need suggestions about how could I rewrite the query to get the same result with less cost of time and resources. I've already created indexes on all foreign key columns. Thanks in advance. Danilo Mota ======================================================================== ============ SELECT sn.notafiscalnumero, sn.notafiscalserie, CASE sn.notafiscaldata WHEN '00000000' THEN NULL ELSE to_date(sn.notafiscaldata,'YYYYMMDD') END, sn.modalidade, rcm.pkclientemarca, sn.notafiscalvalor/100, sn.entrada/100, sn.cliente FROM r_clientemarca AS rcm INNER JOIN r_cliente AS rc ON rc.pkcliente = rcm.fkcliente INNER JOIN sav_cliente_lg AS sc ON sc.cpfcnpj = rc.cpfcnpj INNER JOIN sav_nota_lg AS sn ON sn.cliente = sc.codigo WHERE rcm.fkmarca = 1 AND sn.notafiscalnumero||sn.notafiscalserie||sn.cliente NOT IN ( SELECT numero||serie||codigo FROM r_contrato AS rcon WHERE savfonte = 'lg') ======================================================================== ============ TABLES ------------------------------------------------------------------------ ----------------------------------------------------- r_cliente: 75820 records r_clientemarca: 97719 records r_contrato: 782058 records sav_cliente_lg: 65671 records sav_nota_lg: 297329 rcords MY SERVER ------------------------------------------------------------------------ ----------------------------------------------------- Pentium 4 2.4 GHz 1 GB RAM 36 GB SCSI Postgresql 7.4.2 POSTGRESQL.CONF ------------------------------------------------------------------------ ----------------------------------------------------- shared_buffers = 7800 sort_mem = 4096 checkpoint_segments = 5 effective_cache_size = 12000 cpu_operator_cost = 0.0015 stats_start_collector = false QUERY PLAN ------------------------------------------------------------------------ ----------------------------------------------------- Hash Join (cost=27149.61..3090289650.24 rows=128765 width=4) Hash Cond: ("outer".cliente = "inner".codigo) -> Seq Scan on sav_nota_lg sn (cost=0.00..3090258517.99 rows=148665 width=8) Filter: (NOT (subplan)) SubPlan -> Seq Scan on r_contrato rcon (cost=0.00..20362.47 rows=282845 width=19) Filter: ((savfonte)::text = 'lg'::text) -> Hash (cost=26869.29..26869.29 rows=56880 width=4) -> Hash Join (cost=22473.95..26869.29 rows=56880 width=4) Hash Cond: ("outer".fkcliente = "inner".pkcliente) -> Index Scan using ix_r_clientemarca_fkmarca on r_clientemarca rcm (cost=0.00..2244.46 rows=65665 width=4) Index Cond: (fkmarca = 1) -> Hash (cost=22118.44..22118.44 rows=65672 width=8) -> Hash Join (cost=6613.22..22118.44 rows=65672 width=8) Hash Cond: (("outer".cpfcnpj)::text = ("inner".cpfcnpj)::text) -> Seq Scan on r_cliente rc (cost=0.00..12891.16 rows=75816 width=23) -> Hash (cost=6129.71..6129.71 rows=65671 width=23) -> Seq Scan on sav_cliente_lg sc (cost=0.00..6129.71 rows=65671 width=23) ------=_NextPart_000_0001_01C486F9.3449FFA0 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hi all,=

 <= /font>

 th= e following query is working well without the AND on WHERE clause, so I need suggestions about how could I rewrite the query to get the same result with less cost of time and resources.

 

I’ve already created indexes on all foreign key columns.

 

Thanks in advance.

 

Danilo <= span class=3DSpellE>Mota

 

=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D

    SELECT

        sn.notafiscalnumero,

        sn.notafiscalserie,

        CASE = sn.notafiscaldata WHEN '00000000' THEN NULL ELSE to_date(sn.notafiscaldata,'YYYYMMDD') END,<= /font>

        sn.mo= dalidade,

        rcm.p= kclientemarca,

        sn.no= tafiscalvalor/100,

        sn.entrada/100,

        sn.cliente

    FROM r_clientemarca AS= rcm

    INNER JOIN = r_cliente AS rc ON rc.pkcliente =3D rcm.fk= cliente

    INNER JOIN sav_cliente_lg AS sc ON sc.cpfcnpj =3D rc.cpfcnpj=

    INNER JOIN sav_nota_lg AS sn ON sn.cliente = =3D sc.codigo

    WHERE rcm.fkmarca =3D 1

      AND sn.notafiscalnumero||sn.notafiscalserie||sn.cliente N= OT IN ( SELECT numero||serie||codigo

        =             &nb= sp;            =             &nb= sp;            =                     =             &nb= sp;         FROM r_contrato AS rcon

        =             &nb= sp;            =             &nb= sp;             =                    =             &nb= sp;         WHERE savfonte =3D 'lg')

 <= /font>

=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D

 <= /font>

 

        =             &nb= sp;            =             &nb= sp;           TABLES

-------------------------= ---------------------------------------------------------------------------= -------------------------

r_cliente: 75820 records<= o:p>

r_clientemarca: 97719 rec= ords

r_contrato: 782058 record= s

sav_cliente_lg: 65671 rec= ords

sav_nota_lg: 297329 rcord= s

        =             &nb= sp;            =             &nb= sp;           MY SERVER

--------------------------------------------------------= ---------------------------------------------------------------------<= /o:p>

Pentium 4 2.4 GHz

1 GB RAM

36 GB SCSI

Postgresql 7.4.2

 <= /font>

        =             &nb= sp;            =             &nb= sp;           POSTGRESQL.CONF

--------------------------------------------------------= ---------------------------------------------------------------------<= /o:p>

shared_buffers = =3D 7800

sort_mem<= font size=3D2 face=3DArial> = =3D 4096

checkpoint_segments = =3D 5 

effective_cache_size = =3D 12000

cpu_operator_cost = =3D 0.0015

stats_start_collector = =3D false

 

        =             &nb= sp;            =             &nb= sp;           QUERY PLAN

--------------------------------------------------------= ---------------------------------------------------------------------<= /o:p>

 Hash Join  (co= st=3D27149.61..3090289650.24 rows=3D128765 width=3D4)

   Has= h Cond: ("outer".cliente= =3D "inner".codigo)=

   ->  Seq Scan on sav_nota_lg sn  (cost=3D0.00..3090258517.99 rows=3D148665 width=3D8)

         Filter: (NOT (subplan))

         SubPlan

        =    ->  Seq Scan on r_contrato rcon  (cost=3D0.00..20362.47 rows=3D282845 width=3D19)

        =          Filter: ((savfonte):= :text =3D 'lg'::text)

   ->  Hash  (cost=3D26869.29..26869.29 rows=3D= 56880 width=3D4)

         ->  Hash Join  (cost=3D22473.95..26869.= 29 rows=3D56880 width=3D4)

        =        Hash Cond: ("o= uter".fkcliente =3D "inner".pkcliente)

        =        ->  Index Scan using ix_r_clientemarca_fkmar= ca on r_clientemarca rcm  (cost=3D0.00..2244.46 rows=3D65665= width=3D4)

        =              Index Cond: (fkmarc= a =3D 1)

        =        ->  Hash  (cost=3D22118.44..22118.44 rows=3D= 65672 width=3D8)

               =       ->  Hash Join  (cost=3D6613.22..22118.44 rows=3D65672 width=3D8)

        =             &nb= sp;      Hash Cond: (("= outer".cpfcnpj)::text =3D ("inner".cpfc= npj)::text)

        =             &nb= sp;      ->  Seq Scan on r_cliente rc  (cost=3D0.00..12891.16 rows=3D75816 width=3D23)

        =             &nb= sp;      ->  Hash  (cost=3D6129.71..6129.71 rows=3D65= 671 width=3D23)

        =             &nb= sp;            ->  Seq Scan on sav_cliente_l= g sc  (cost=3D0.00..6129.71 rows= =3D65671 width=3D23)

 

 

------=_NextPart_000_0001_01C486F9.3449FFA0-- From brad@madfish.com Sat Aug 21 00:59:51 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 671155E46BF for ; Fri, 20 Aug 2004 21:59:51 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 55195-01 for ; Sat, 21 Aug 2004 00:59:49 +0000 (GMT) Received: from bugge.potatoe.com (bugge.potatoe.com [216.240.48.15]) by svr1.postgresql.org (Postfix) with ESMTP id C639C5E37CB for ; Fri, 20 Aug 2004 21:59:46 -0300 (ADT) Received: from [127.0.0.1] (localhost [127.0.0.1]) by bugge.potatoe.com (Postfix) with ESMTP id 59151728DE5; Fri, 20 Aug 2004 18:02:49 -0700 (PDT) Message-ID: <41269F38.5090305@madfish.com> Date: Fri, 20 Aug 2004 18:02:48 -0700 From: Brad Bulger Organization: The Madfish Group User-Agent: Mozilla Thunderbird 0.7+ (Macintosh/20040715) X-Accept-Language: en-us, en MIME-Version: 1.0 To: dmota@nexen.com.br Cc: pgsql-performance@postgresql.org Subject: Re: Query Performance References: <000001c48712$599737a0$8afea8c0@nexen.lan> In-Reply-To: <000001c48712$599737a0$8afea8c0@nexen.lan> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/311 X-Sequence-Number: 7947 Have you tried AND (sn.notafiscalnumero, sn.notafiscalserie, sn.cliente) NOT IN ( SELECT numero, serie, codigo FROM r_contrato WHERE savfonte = 'lg') or and not exists(select true from r_contrato where savfonte = 'lg' and numero = sn.notafiscalnumero and serie = sn.notafiscalserie and codigo = sn.cliente) Danilo Mota wrote: > Hi all, > > > > the following query is working well without the AND on WHERE clause, so > I need suggestions about how could I rewrite the query to get the same > result with less cost of time and resources. > > > > I’ve already created indexes on all foreign key columns. > > > > Thanks in advance. > > > > Danilo Mota > > > > ==================================================================================== > > SELECT > > sn.notafiscalnumero, > > sn.notafiscalserie, > > CASE sn.notafiscaldata WHEN '00000000' THEN NULL ELSE > to_date(sn.notafiscaldata,'YYYYMMDD') END, > > sn.modalidade, > > rcm.pkclientemarca, > > sn.notafiscalvalor/100, > > sn.entrada/100, > > sn.cliente > > FROM r_clientemarca AS rcm > > INNER JOIN r_cliente AS rc ON rc.pkcliente = rcm.fkcliente > > INNER JOIN sav_cliente_lg AS sc ON sc.cpfcnpj = rc.cpfcnpj > > INNER JOIN sav_nota_lg AS sn ON sn.cliente = sc.codigo > > WHERE rcm.fkmarca = 1 > > AND sn.notafiscalnumero||sn.notafiscalserie||sn.cliente NOT IN ( > SELECT numero||serie||codigo > > > FROM r_contrato AS rcon > > > WHERE savfonte = 'lg') > > > > ==================================================================================== > > > > > > TABLES > > ----------------------------------------------------------------------------------------------------------------------------- > > r_cliente: 75820 records > > r_clientemarca: 97719 records > > r_contrato: 782058 records > > sav_cliente_lg: 65671 records > > sav_nota_lg: 297329 rcords > > MY SERVER > > ----------------------------------------------------------------------------------------------------------------------------- > > Pentium 4 2.4 GHz > > 1 GB RAM > > 36 GB SCSI > > Postgresql 7.4.2 > > > > POSTGRESQL.CONF > > ----------------------------------------------------------------------------------------------------------------------------- > > shared_buffers = 7800 > > sort_mem = 4096 > > checkpoint_segments = 5 > > effective_cache_size = 12000 > > cpu_operator_cost = 0.0015 > > stats_start_collector = false > > > > QUERY PLAN > > ----------------------------------------------------------------------------------------------------------------------------- > > Hash Join (cost=27149.61..3090289650.24 rows=128765 width=4) > > Hash Cond: ("outer".cliente = "inner".codigo) > > -> Seq Scan on sav_nota_lg sn (cost=0.00..3090258517.99 rows=148665 > width=8) > > Filter: (NOT (subplan)) > > SubPlan > > -> Seq Scan on r_contrato rcon (cost=0.00..20362.47 > rows=282845 width=19) > > Filter: ((savfonte)::text = 'lg'::text) > > -> Hash (cost=26869.29..26869.29 rows=56880 width=4) > > -> Hash Join (cost=22473.95..26869.29 rows=56880 width=4) > > Hash Cond: ("outer".fkcliente = "inner".pkcliente) > > -> Index Scan using ix_r_clientemarca_fkmarca on > r_clientemarca rcm (cost=0.00..2244.46 rows=65665 width=4) > > Index Cond: (fkmarca = 1) > > -> Hash (cost=22118.44..22118.44 rows=65672 width=8) > > -> Hash Join (cost=6613.22..22118.44 rows=65672 > width=8) > > Hash Cond: (("outer".cpfcnpj)::text = > ("inner".cpfcnpj)::text) > > -> Seq Scan on r_cliente rc > (cost=0.00..12891.16 rows=75816 width=23) > > -> Hash (cost=6129.71..6129.71 rows=65671 > width=23) > > -> Seq Scan on sav_cliente_lg sc > (cost=0.00..6129.71 rows=65671 width=23) > > > > > From loquin@talleyds.com Fri Mar 11 18:48:29 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D542B5651C for ; Fri, 11 Mar 2005 18:48:29 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 34045-07 for ; Fri, 11 Mar 2005 18:48:20 +0000 (GMT) Received: from mesagate.talleyds.com (unknown [207.114.138.130]) by svr1.postgresql.org (Postfix) with ESMTP id 35C0F563DE for ; Fri, 11 Mar 2005 18:48:18 +0000 (GMT) Received: from TDS-MTA by mesagate.talleyds.com with Novell_GroupWise; Fri, 11 Mar 2005 11:48:19 -0700 Message-Id: X-Mailer: Novell GroupWise Internet Agent 6.5.4 Date: Fri, 11 Mar 2005 11:47:54 -0700 From: "Lou O'Quin" To: Subject: Query performance Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="=__Part361548CA.0__=" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.505 tagged_above=0 required=5 tests=HTML_20_30, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200503/191 X-Sequence-Number: 10896 --=__Part361548CA.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable As a test, I ran a query in the pgAdmin query tool, which returns about = 15K records from a PostgreSQL v8.01 table on my Win2K server. I ran the same query from the local server, from another PC on the same = 100 mbit local network, and from a PC on a different network, over the = internet.=20 The times for the query to run and the data to return for each of the = three=20 locations are shown here: Local Server : 571+521 ms Local network: = 1187+1266 ms Internet:14579+4016 msMy question is this: Why does the = execution time for the query to run increase so much? Since the query = should be running on the server, it's time should be somewhat independent = of the network transport delay. (unlike the data transport time) However, = it appears to actually be hypersensitive to the transport delay. The = ratios of time for the data transport (assuming 1 for the local server) = are: 1 : 2.43 : 7.71 whereas the query execution time ratios are: 1 : 2.08 : 25.5 (!!!) Obviously, the transport times will be greater. But why does the = execution time bloat so? --=__Part361548CA.0__= Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Description: HTML As a = test, I ran a query in the pgAdmin query tool, which returns about 15K = records from a PostgreSQL v8.01 table on my Win2K server.

I ran the = same query from the local server, from another PC on the same 100 mbit = local network, and from a PC on a different network, over the internet. =

The times for the query to run and the data to return for each of = the three
locations are shown here:=20
  • Local Server : 571+521 ms=20
  • Local network: 1187+1266 ms=20
  • Internet:14579+4016 ms
My question is this: Why does the = execution time for the query to run increase so much? Since the query = should be running on the server, it's time should be somewhat = independent of the network transport delay. (unlike the data transport = time) However, it appears to actually be hypersensitive to the transport = delay. The ratios of time for the data transport (assuming 1 for the local = server) are:
1 : 2.43 : 7.71

whereas the query execution = time ratios are:
1 : 2.08 : 25.5  (!!!)

Obviousl= y, the transport times will be greater.  But why does the execution = time bloat so? --=__Part361548CA.0__=-- From tgl@sss.pgh.pa.us Fri Mar 11 19:10:36 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 73021563E7 for ; Fri, 11 Mar 2005 19:10:36 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 39460-05 for ; Fri, 11 Mar 2005 19:10:28 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id B7BFA55119 for ; Fri, 11 Mar 2005 19:10:27 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2BJARqu004476; Fri, 11 Mar 2005 14:10:27 -0500 (EST) To: "Lou O'Quin" Cc: pgsql-performance@postgresql.org Subject: Re: Query performance In-reply-to: References: Comments: In-reply-to "Lou O'Quin" message dated "Fri, 11 Mar 2005 11:47:54 -0700" Date: Fri, 11 Mar 2005 14:10:27 -0500 Message-ID: <4475.1110568227@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/192 X-Sequence-Number: 10897 "Lou O'Quin" writes: > it appears to actually be hypersensitive to the transport delay. The = > ratios of time for the data transport (assuming 1 for the local server) = > are: > 1 : 2.43 : 7.71 > whereas the query execution time ratios are: > 1 : 2.08 : 25.5 (!!!) How do you know that's what the data transport time is --- ie, how can you measure that separately from the total query time? regards, tom lane From loquin@talleyds.com Fri Mar 11 19:38:41 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AC4A35644B for ; Fri, 11 Mar 2005 19:38:41 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 45702-10 for ; Fri, 11 Mar 2005 19:38:32 +0000 (GMT) Received: from mesagate.talleyds.com (unknown [207.114.138.130]) by svr1.postgresql.org (Postfix) with ESMTP id 9F53754469 for ; Fri, 11 Mar 2005 19:38:30 +0000 (GMT) Received: from TDS-MTA by mesagate.talleyds.com with Novell_GroupWise; Fri, 11 Mar 2005 12:38:31 -0700 Message-Id: X-Mailer: Novell GroupWise Internet Agent 6.5.4 Date: Fri, 11 Mar 2005 12:38:16 -0700 From: "Lou O'Quin" To: Cc: Subject: Re: Query performance Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="=__Part50732EB8.0__=" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.281 tagged_above=0 required=5 tests=AWL, HTML_30_40, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200503/193 X-Sequence-Number: 10898 --=__Part50732EB8.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hi Tom. I referenced the status line of pgAdmin. Per the pgAdmin help = file: =20 "The status line will show how long the last query took to complete. If a = dataset was returned, not only the elapsed time for server execution is = displayed, but also the time to retrieve the data from the server to the = Data Output page." =20 Lou >>> Tom Lane 3/11/2005 12:10 PM >>> "Lou O'Quin" writes: > it appears to actually be hypersensitive to the transport delay. The =3D > ratios of time for the data transport (assuming 1 for the local server) = =3D > are: > 1 : 2.43 : 7.71 > whereas the query execution time ratios are: > 1 : 2.08 : 25.5 (!!!) How do you know that's what the data transport time is --- ie, how can you measure that separately from the total query time? regards, tom lane --=__Part50732EB8.0__= Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Description: HTML
Hi Tom.  I referenced the status line of pgAdmin.  Per = the pgAdmin help file:
 
"The status line will show how long the last query took to complete. = If a dataset was returned, not only the elapsed time for server execution = is displayed, but also the time to retrieve the data from the server to = the Data Output page."
 
Lou

>>> Tom Lane <tgl@sss.pgh.pa.us> 3/11/2005 = 12:10 PM >>>
"Lou O'Quin" <loquin@talleyds.com> = writes:
> it appears to actually be hypersensitive to the transport = delay. The =3D
> ratios of time for the data transport (assuming 1 = for the local server) =3D
> are:
> 1 : 2.43 : 7.71

> = whereas the query execution time ratios are:
> 1 : 2.08 : 25.5  = (!!!)

How do you know that's what the data transport time is --- = ie, how can
you measure that separately from the total query time?
            regards, tom = lane
--=__Part50732EB8.0__=-- From tgl@sss.pgh.pa.us Fri Mar 11 20:21:21 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id ABAF7565E1 for ; Fri, 11 Mar 2005 20:21:21 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 58703-08 for ; Fri, 11 Mar 2005 20:21:12 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id CA160565AC for ; Fri, 11 Mar 2005 20:21:11 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2BKLCav004961; Fri, 11 Mar 2005 15:21:12 -0500 (EST) To: "Lou O'Quin" Cc: pgsql-performance@postgresql.org Subject: Re: Query performance In-reply-to: References: Comments: In-reply-to "Lou O'Quin" message dated "Fri, 11 Mar 2005 12:38:16 -0700" Date: Fri, 11 Mar 2005 15:21:12 -0500 Message-ID: <4960.1110572472@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/195 X-Sequence-Number: 10900 "Lou O'Quin" writes: > Hi Tom. I referenced the status line of pgAdmin. Per the pgAdmin help > file: > > "The status line will show how long the last query took to complete. If a > dataset was returned, not only the elapsed time for server execution is > displayed, but also the time to retrieve the data from the server to the > Data Output page." Well, you should probably ask the pgadmin boys exactly what they are measuring. In any case, the Postgres server overlaps query execution with result sending, so I don't think it's possible to get a pure measurement of just one of those costs --- certainly not by looking at it only from the client end. BTW, one factor to consider is that if the test client machines weren't all the same speed, that would have some impact on their ability to absorb 15K records ... regards, tom lane From loquin@talleyds.com Fri Mar 11 20:35:32 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2E31056616 for ; Fri, 11 Mar 2005 20:35:32 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 63693-04 for ; Fri, 11 Mar 2005 20:35:22 +0000 (GMT) Received: from mesagate.talleyds.com (unknown [207.114.138.130]) by svr1.postgresql.org (Postfix) with ESMTP id 460A85661A for ; Fri, 11 Mar 2005 20:35:20 +0000 (GMT) Received: from TDS-MTA by mesagate.talleyds.com with Novell_GroupWise; Fri, 11 Mar 2005 13:35:22 -0700 Message-Id: X-Mailer: Novell GroupWise Internet Agent 6.5.4 Date: Fri, 11 Mar 2005 13:35:03 -0700 From: "Lou O'Quin" To: Cc: Subject: Re: Query performance Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="=__PartFFDC82E7.0__=" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.384 tagged_above=0 required=5 tests=AWL, HTML_20_30, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200503/197 X-Sequence-Number: 10902 --=__PartFFDC82E7.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable I'll post there concerning how they determine the query execution time vs. = data retrieval time. =20 I did think about the processor/memory when choosing the machines - all = three of the processors are similar. All are Pentium P4s with 512 MB = memory. the server is Win2K, P4, 2.3 gHz the local network client is a WinXP Pro, P4, 2.2 gHz the remote network client is WinXP Pro, P4, 1.9 gHz =20 Lou >>> Tom Lane 3/11/2005 1:21 PM >>> "Lou O'Quin" writes: > Hi Tom. I referenced the status line of pgAdmin. Per the pgAdmin help > file: > > "The status line will show how long the last query took to complete. If = a > dataset was returned, not only the elapsed time for server execution is > displayed, but also the time to retrieve the data from the server to the > Data Output page." Well, you should probably ask the pgadmin boys exactly what they are measuring. In any case, the Postgres server overlaps query execution with result sending, so I don't think it's possible to get a pure measurement of just one of those costs --- certainly not by looking at it only from the client end. BTW, one factor to consider is that if the test client machines weren't all the same speed, that would have some impact on their ability to absorb 15K records ... regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match --=__PartFFDC82E7.0__= Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Description: HTML
I'll post there concerning how they determine the query execution = time vs. data retrieval time.
 
I did think about the processor/memory when choosing the machines - = all three of the processors are similar.  All are Pentium P4s with = 512 MB memory.
the server is Win2K, P4, 2.3 gHz
the local network client  is a WinXP Pro, P4, 2.2 gHz
the = remote network client is WinXP Pro, P4, 1.9 gHz
 
Lou

>>> Tom Lane <tgl@sss.pgh.pa.us> 3/11/2005 1:21 PM = >>>
"Lou O'Quin" <loquin@talleyds.com> = writes:
> Hi Tom.  I referenced the status line of pgAdmin. = ; Per the pgAdmin help
> file:
>
> "The status line will = show how long the last query took to complete. If a
> dataset was = returned, not only the elapsed time for server execution is
> = displayed, but also the time to retrieve the data from the server to = the
> Data Output page."

Well, you should probably ask the = pgadmin boys exactly what they are
measuring.  In any case, the = Postgres server overlaps query execution
with result sending, so I = don't think it's possible to get a pure
measurement of just one of = those costs --- certainly not by looking at
it only from the client = end.

BTW, one factor to consider is that if the test client = machines weren't
all the same speed, that would have some impact on = their ability to
absorb 15K records ...

    =         regards, tom lane

------------= ---------------(end of broadcast)---------------------------
TIP 9: the = planner will ignore your desire to choose an index scan if your
 &n= bsp;    joining column's datatypes do not match
--=__PartFFDC82E7.0__=-- From sgunderson@bigfoot.com Mon May 22 23:33:44 2006 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 5792D9FA2D8 for ; Mon, 22 May 2006 20:33:44 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 52623-08 for ; Mon, 22 May 2006 20:33:35 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) by postgresql.org (Postfix) with ESMTP id 7AB139F9B14 for ; Mon, 22 May 2006 20:33:35 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 2453831932; Tue, 23 May 2006 01:33:34 +0200 (MET DST) From: "Steinar H. Gunderson" X-Newsgroups: comp.databases.postgresql,pgsql.performance Subject: Re: Query performance Date: Mon, 22 May 2006 23:33:33 +0000 (UTC) Organization: /etc/news/organization Lines: 20 Message-ID: References: X-Complaints-To: usenet@itea.ntnu.no User-Agent: slrn/0.9.8.1pl1 (Debian) To: pgsql-performance@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/427 X-Sequence-Number: 19214 antonio.batovanja@humanomed.co.at wrote: > The above query takes 5 seconds to execute! > > [...] > > Total runtime: 96109.571 ms It sure doesn't look like it... > Total runtime: 461.907 ms > > [...] > > Suddenly the query takes only 0.29 seconds! How are you timing this, really? /* Steinar */ -- Homepage: http://www.sesse.net/ From antonio.batovanja@humanomed.co.at Tue May 23 07:11:11 2006 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id D84F89F9EEB for ; Tue, 23 May 2006 04:11:11 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 17638-02 for ; Tue, 23 May 2006 04:11:06 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) by postgresql.org (Postfix) with ESMTP id AB70D9F9CAA for ; Tue, 23 May 2006 04:11:05 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 1603731932; Tue, 23 May 2006 09:11:04 +0200 (MET DST) From: Antonio Batovanja X-Newsgroups: comp.databases.postgresql,pgsql.performance Subject: Re: Query performance Followup-To: comp.databases.postgresql Date: Tue, 23 May 2006 09:10:29 +0200 Organization: Humanomed Lines: 29 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Complaints-To: abuse@uta.at User-Agent: KNode/0.9.2 To: pgsql-performance@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/538 X-Sequence-Number: 19325 Steinar H. Gunderson wrote: > antonio.batovanja@humanomed.co.at wrote: >> The above query takes 5 seconds to execute! >> >> [...] >> >> Total runtime: 96109.571 ms > > It sure doesn't look like it... > >> Total runtime: 461.907 ms >> >> [...] >> >> Suddenly the query takes only 0.29 seconds! > > How are you timing this, really? > > /* Steinar */ I'm executing the queries from phpPgAdmin. The above are for explain analyse. I was referring to the pure query execution time. Does anyone have an idea why the OR-query takes so long? Any server-side tuning possibilities? I wouldn't like to change the code of ldap's back-sql... Toni From brsaweda@gmail.com Sun May 28 21:56:42 2006 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 503ED9FA5D8 for ; Sun, 28 May 2006 18:56:42 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 76349-03 for ; Sun, 28 May 2006 18:56:31 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) by postgresql.org (Postfix) with ESMTP id 1A6059F9F3D for ; Sun, 28 May 2006 18:56:31 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 9826831963; Sun, 28 May 2006 23:56:29 +0200 (MET DST) Date: Sun, 28 May 2006 23:56:27 +0200 From: Erwin Brandstetter User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) MIME-Version: 1.0 X-Newsgroups: comp.databases.postgresql,pgsql.performance Subject: Re: Query performance References: <1148294589.715695@proxy.dienste.wien.at> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: X-Complaints-To: abuse@chello.at Organization: chello.at Lines: 30 To: pgsql-performance@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/547 X-Sequence-Number: 19334 Antonio Batovanja wrote: > Laurenz Albe wrote: > >> Antonio Batovanja wrote: >>> I'm having trouble understanding, why a specific query on a small >>> database is taking so long... >>> >> Before I try to understand the execution plans: >> >> Have you run ANALYZE on the tables involved before you ran the query? > > Hi, > > Just to be on the safe side, I've run ANALYZE now. > Here are the query plans for the two queries: I suspect a misunderstanding here. What Laurenz probably meant is to run analyze on the involved _tables_ so the statistics data is refreshed. If the query planner runs with outdated statistics, queries may perform very poorly. Try vacuum full analyze yourdatabase To fully vacuum your database and analyze all tables. (vacuum full is extra, but can't hurt.) http://www.postgresql.org/docs/8.1/static/sql-vacuum.html http://www.postgresql.org/docs/8.1/static/sql-analyze.html Regards, Erwin From brsaweda@gmail.com Sun May 28 22:39:05 2006 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 9A7909FA48C for ; Sun, 28 May 2006 19:39:05 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 81906-09 for ; Sun, 28 May 2006 19:38:58 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) by postgresql.org (Postfix) with ESMTP id 624699FA131 for ; Sun, 28 May 2006 19:38:59 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 73C8931963; Mon, 29 May 2006 00:38:57 +0200 (MET DST) Date: Mon, 29 May 2006 00:38:55 +0200 From: Erwin Brandstetter User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) MIME-Version: 1.0 X-Newsgroups: comp.databases.postgresql,pgsql.performance Subject: Re: Query performance References: <1148294589.715695@proxy.dienste.wien.at> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: X-Complaints-To: abuse@chello.at Organization: chello.at Lines: 65 To: pgsql-performance@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/546 X-Sequence-Number: 19333 Antonio Batovanja wrote: (...) > 1) the slooooow query: > EXPLAIN ANALYZE SELECT DISTINCT ldap_entries.id, organization.id, > text('organization') AS objectClass, ldap_entries.dn AS dn FROM > ldap_entries, organization, ldap_entry_objclasses WHERE > organization.id=ldap_entries.keyval AND ldap_entries.oc_map_id=1 AND > upper(ldap_entries.dn) LIKE '%DC=HUMANOMED,DC=AT' AND 1=1 OR > (ldap_entries.id=ldap_entry_objclasses.entry_id AND > ldap_entry_objclasses.oc_name='organization'); First, presenting your query in any readable form might be helpful if you want the community to help you. (Hint! Hint!) SELECT DISTINCT ldap_entries.id, organization.id, text('organization') AS objectClass, ldap_entries.dn AS dn FROM ldap_entries, organization, ldap_entry_objclasses WHERE organization.id=ldap_entries.keyval AND ldap_entries.oc_map_id=1 AND upper(ldap_entries.dn) LIKE '%DC=HUMANOMED,DC=AT' AND 1=1 OR (ldap_entries.id=ldap_entry_objclasses.entry_id AND ldap_entry_objclasses.oc_name='organization'); Next, you might want to use aliases to make it more readable. SELECT DISTINCT e.id, o.id, text('organization') AS objectClass, e.dn AS dn FROM ldap_entries AS e, organization AS o, ldap_entry_objclasses AS eo WHERE o.id=e.keyval AND e.oc_map_id=1 AND upper(e.dn) LIKE '%DC=HUMANOMED,DC=AT' AND 1=1 OR (e.id=eo.entry_id AND eo.oc_name='organization'); There are a couple redundant (nonsensical) items, syntax-wise. Let's strip these: SELECT DISTINCT e.id, o.id, text('organization') AS objectClass, e.dn FROM ldap_entries AS e, organization AS o, ldap_entry_objclasses AS eo WHERE o.id=e.keyval AND e.oc_map_id=1 AND e.dn ILIKE '%DC=HUMANOMED,DC=AT' OR e.id=eo.entry_id AND eo.oc_name='organization'; And finally, I suspect the lexical precedence of AND and OR might be the issue here. http://www.postgresql.org/docs/8.1/static/sql-syntax.html#SQL-PRECEDENCE Maybe that is what you really want (just guessing): SELECT DISTINCT e.id, o.id, text('organization') AS objectClass, e.dn FROM ldap_entries e JOIN organization o ON o.id=e.keyval LEFT JOIN ldap_entry_objclasses eo ON eo.entry_id=e.id WHERE e.oc_map_id=1 AND e.dn ILIKE '%DC=HUMANOMED,DC=AT' OR eo.oc_name='organization)'; I didn't take the time to read the rest. My appologies if I guessed wrong. Regards, Erwin From chris.kings-lynne@calorieking.com Wed May 31 01:36:04 2006 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id A5F099FA5F0 for ; Tue, 30 May 2006 22:36:04 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 45145-09 for ; Tue, 30 May 2006 22:35:58 -0300 (ADT) X-Greylist: delayed 00:31:42.956827 by SQLgrey- Received: from houston.familyhealth.com.au (iihouston.familyhealth.com.au [203.59.102.239]) by postgresql.org (Postfix) with ESMTP id DD8709FA5E1 for ; Tue, 30 May 2006 22:35:58 -0300 (ADT) Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) by houston.familyhealth.com.au (Postfix) with ESMTP id D0DF62573F; Wed, 31 May 2006 09:04:11 +0800 (WST) Received: from [127.0.0.1] (work-48.internal [192.168.0.48]) by houston.familyhealth.com.au (Postfix) with ESMTP id 4354C2573B; Wed, 31 May 2006 09:04:09 +0800 (WST) Message-ID: <447CEC56.3070106@calorieking.com> Date: Wed, 31 May 2006 09:07:34 +0800 From: Christopher Kings-Lynne User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) MIME-Version: 1.0 To: Antonio Batovanja Cc: pgsql-performance@postgresql.org Subject: Re: Query performance References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-familyhealth-MailScanner-Information: Please contact the ISP for more information X-familyhealth-MailScanner: Found to be clean X-familyhealth-MailScanner-From: chris.kings-lynne@calorieking.com X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/560 X-Sequence-Number: 19347 > I'm executing the queries from phpPgAdmin. > The above are for explain analyse. I was referring to the pure query > execution time. > Does anyone have an idea why the OR-query takes so long? > Any server-side tuning possibilities? I wouldn't like to change the code of > ldap's back-sql... If you're using phpPgAdmin's timings, they could be more off than the real explain analyze timings. Make sure you're using the figure given by explain analyze itself. Chris From kpmanojpg@gmail.com Thu Jun 13 07:56:48 2013 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Un2Om-0001yH-9r for pgsql-performance@arkaria.postgresql.org; Thu, 13 Jun 2013 07:56:48 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Un2Ol-0007oP-L1 for pgsql-performance@arkaria.postgresql.org; Thu, 13 Jun 2013 07:56:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Un2Ok-0007oK-Gj for pgsql-performance@postgresql.org; Thu, 13 Jun 2013 07:56:46 +0000 Received: from mail-pb0-x244.google.com ([2607:f8b0:400e:c01::244]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Un2Og-0002Sp-OD for pgsql-performance@postgresql.org; Thu, 13 Jun 2013 07:56:45 +0000 Received: by mail-pb0-f68.google.com with SMTP id jt11so5795339pbb.3 for ; Thu, 13 Jun 2013 00:56:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=ULCCvAjXRMDsOHgyrjy07li/TKL/F7O3y75R1lXjYiI=; b=QECDOqXDIw3EBMkNGDJFejnr0QsDXaMtosgwCro5WprpHr4nSSBekrV9fpYTzSbREQ PS3HvJaiM79DqhD+zZ68vzM6h0HNTuuGDUCXo9gMxpYJB4FLXp8KIfZ65qDOhDrQd/fa OuoNpw+ahsX1CRcOgW30/NGsMPM4zQxOrjzh4HSAq0z9ZJ0NWs0gWBcs2xb9Q40xn1G0 zQQDDwLf9VMDxrKHv0JVnPRjxcdh+PzGru+BjSvbQ4syjg7PMk6yUhch87MGcQmq90DP Uo/FLWXJX/SKGK+1H0CNt6CnVcaYRU56zSKlp75zxDAaW1VbMBxtnh9NdviU03F2egxo 8cVw== MIME-Version: 1.0 X-Received: by 10.68.200.133 with SMTP id js5mr13763431pbc.22.1371109782694; Thu, 13 Jun 2013 00:49:42 -0700 (PDT) Received: by 10.70.102.66 with HTTP; Thu, 13 Jun 2013 00:49:42 -0700 (PDT) Date: Thu, 13 Jun 2013 13:19:42 +0530 Message-ID: Subject: Query performance From: K P Manoj To: pgsql-performance@postgresql.org Content-Type: multipart/alternative; boundary=047d7b15a99f8bb1e104df045f25 X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org --047d7b15a99f8bb1e104df045f25 Content-Type: text/plain; charset=ISO-8859-1 Hi All One of my query treating performance issue on my production server. Once i run query on my parent table with specific condition(hard coded value) its uses only proper child table and its index on explain plan , but once i am using table conditions (instead of hard coded value), query planner is going all the child tables, Can i know where i am worng Postgresql version 9.2.2 Please find details below ========================== XXX_db=> select id from xxx where d_id = '5'; id ------- 5 45 (2 rows) XXX_db=> explain analyze SELECT * FROM xxx_parent_table WHERE id in (5,45) and ( sts = 1 or status is null ) order by creation_time limit 40 ; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------- - Limit (cost=12.21..12.21 rows=3 width=251) (actual time=6.585..6.585 rows=0 loops=1) -> Sort (cost=12.21..12.21 rows=3 width=251) (actual time=6.582..6.582 rows=0 loops=1) Sort Key: public.xxx_parent_tables.creation_time Sort Method: quicksort Memory: 25kB -> Result (cost=0.00..12.18 rows=3 width=251) (actual time=6.571..6.571 rows=0 loops=1) -> Append (cost=0.00..12.18 rows=3 width=251) (actual time=6.569..6.569 rows=0 loops=1) -> Seq Scan on xxx_parent_tables (cost=0.00..0.00 rows=1 width=324) (actual time=0.003..0.003 rows=0 loops=1) Filter: ((id = ANY ('{5,45}'::bigint[])) AND ((status = 1) OR (status IS NULL))) -> Bitmap Heap Scan on xxx_parent_tables_table_details_ xxx_parent_tables (cost=4.52..6.53 rows=1 width=105) (actual ti me=0.063..0.063 rows=0 loops=1) Recheck Cond: ((status = 1) OR (status IS NULL)) Filter: (id = ANY ('{5,45}'::bigint[])) -> BitmapOr (cost=4.52..4.52 rows=1 width=0) (actual time=0.059..0.059 rows=0 loops=1) -> Bitmap Index Scan on xxx_parent_tables_table_details__status_idx (cost=0.00..2.26 rows=1 width=0) (actual time=0.038..0.038 rows=0 loops=1) Index Cond: (status = 1) -> Bitmap Index Scan on xxx_parent_tables_table_details__status_idx (cost=0.00..2.26 rows=1 width=0) (actual time=0.019..0.019 rows=0 loops=1) Index Cond: (status IS NULL) -> Bitmap Heap Scan on xxx_parent_tables_table_details_det xxx_parent_tables (cost=2.52..5.65 rows=1 width=324) (actual ti me=6.502..6.502 rows=0 loops=1) Recheck Cond: (id = ANY ('{5,45}'::bigint[])) Filter: ((status = 1) OR (status IS NULL)) -> Bitmap Index Scan on xxx_parent_tables_table_details_id_idx (cost=0.00..2.52 rows=2 width=0) (actua l time=6.499..6.499 rows=0 loops=1) Index Cond: (id = ANY ('{5,45}'::bigint[])) Total runtime: 6.823 ms (22 rows) XXX_db => explain analyze SELECT * FROM xxx_parent_tables WHERE cp_id in (select id from xxx where d_id = '5') and ( status = 1 or status is null ) order by creation_time limit 40 ; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------ Limit (cost=3.66..6067.89 rows=40 width=105) (actual time=70479.596..70479.596 rows=0 loops=1) -> Nested Loop Semi Join (cost=3.66..4587291.92 rows=30258 width=105) (actual time=70479.593..70479.593 rows=0 loops=1) Join Filter: (public.xxx_parent_tables.cp_id = cp_info.cp_id) Rows Removed by Join Filter: 1416520 -> Merge Append (cost=3.66..4565956.68 rows=711059 width=105) (actual time=67225.964..69635.016 rows=708260 loops=1) Sort Key: public.xxx_parent_tables.creation_time -> Sort (cost=0.01..0.02 rows=1 width=324) (actual time=0.018..0.018 rows=0 loops=1) Sort Key: public.xxx_parent_tables.creation_time Sort Method: quicksort Memory: 25kB -> Seq Scan on xxx_parent_tables (cost=0.00..0.00 rows=1 width=324) (actual time=0.011..0.011 rows=0 loops=1) Filter: ((status = 1) OR (status IS NULL)) -> Index Scan using xxx_parent_tables_automobiles_carwale_creation_time_idx on xxx_parent_tables_automobiles_carwale xxx_parent_tables (co st=0.00..649960.44 rows=17 width=105) (actual time=10219.559..10219.559 rows=0 loops=1) Filter: ((status = 1) OR (status IS NULL)) Rows Removed by Filter: 3102241 -> Index Scan using xxx_parent_tables_automobiles_sulekha_creation_time_idx on xxx_parent_tables_automobiles_sulekha xxx_parent_tables (co st=0.00..1124998.57 rows=1 width=105) (actual time=17817.577..17817.577 rows=0 loops=1) Filter: ((status = 1) OR (status IS NULL)) Rows Removed by Filter: 4016234 -> Index Scan using xxx_parent_tables_automobiles_verse_creation_time_idx on xxx_parent_tables_automobiles_verse xxx_parent_tables (cost=0 .00..24068.88 rows=1 width=103) (actual time=675.291..675.291 rows=0 loops=1) Filter: ((status = 1) OR (status IS NULL)) Rows Removed by Filter: 420616 -> Index Scan using xxx_parent_tables_automobiles_yolist_creation_time_idx on xxx_parent_tables_automobiles_yolist xxx_parent_tables (cost =0.00..25.05 rows=2 width=324) (actual time=0.016..0.016 rows=0 loops=1) Filter: ((status = 1) OR (status IS NULL)) -> Index Scan using xxx_parent_tables_deals_bagittoday_creation_time_idx on xxx_parent_tables_deals_bagittoday xxx_parent_tables (cost=0.0 0..23882.78 rows=1 width=105) (actual time=234.672..234.672 rows=0 loops=1) Filter: ((status = 1) OR (status IS NULL)) Rows Removed by Filter: 84988 -> Index Scan using xxx_parent_tables_deals_bindaasbargain_creation_time_idx on xxx_parent_tables_deals_bindaasbargain xxx_parent_tables ( cost=0.00..25.05 rows=2 width=324) (actual time=0.016..0.016 rows=0 loops=1) Filter: ((status = 1) OR (status IS NULL)) -> Index Scan using xxx_parent_tables_deals_buzzr_creation_time_idx on xxx_parent_tables_deals_buzzr xxx_parent_tables (cost=0.00..11435.4 1 rows=1 width=105) (actual time=109.466..109.466 rows=0 loops=1) Filter: ((status = 1) OR (status IS NULL)) Rows Removed by Filter: 33750 -> Index Scan using xxx_parent_tables_deals_dealdrums_creation_time_idx on xxx_parent_tables_deals_dealdrums xxx_parent_tables (cost=0.00. .51.61 rows=1 width=105) (actual time=0.917..0.917 rows=0 loops=1) Filter: ((status = 1) OR (status IS NULL)) Rows Removed by Filter: 941 -> Index Scan using xxx_parent_tables_deals_dealsandyou_creation_time_idx on xxx_parent_tables_deals_dealsandyou xxx_parent_tables (cost=0 .00..25.05 rows=2 width=324) (actual time=0.012..0.012 rows=0 loops=1) Filter: ((status = 1) OR (status IS NULL)) -> Index Scan using xxx_parent_tables_deals_foodiebay_creation_time_idx on xxx_parent_tables_deals_foodiebay xxx_parent_tables (cost=0.00. .25.05 rows=2 width=324) (actual time=0.024..0.024 rows=0 loops=1) Filter: ((status = 1) OR (status IS NULL)) -> Index Scan using xxx_parent_tables_deals_futurebazaar_creation_time_idx on xxx_parent_tables_deals_futurebazaar xxx_parent_tables (cost =0.00..30.37 rows=1 width=109) (actual time=0.348..0.348 rows=0 loops=1) Filter: ((status = 1) OR (status IS NULL)) -> Index Scan using xxx_parent_tables_jobs_jobsa1_creation_time_idx on xxx_parent_tables_jobs_jobsa1 xxx_parent_tables (cost=0.00..25.05 r ows=2 width=324) (actual time=0.020..0.020 rows=0 loops=1) Filter: ((status = 1) OR (status IS NULL)) -> Index Scan using xxx_parent_tables_jobs_jobsinnigeria_creation_time_idx on xxx_parent_tables_jobs_jobsinnigeria xxx_parent_tables (cost =0.00..25.05 rows=2 width=324) (actual time=0.013..0.013 rows=0 loops=1) Filter: ((status = 1) OR (status IS NULL)) -> Index Scan using xxx_parent_tables_jobs_khojle_creation_time_idx on xxx_parent_tables_jobs_khojle xxx_parent_tables (cost=0.00..25.05 r ows=2 width=324) (actual time=0.013..0.013 rows=0 loops=1) Filter: ((status = 1) OR (status IS NULL)) -> Index Scan using xxx_parent_tables_jobs_midday_creation_time_idx on xxx_parent_tables_jobs_midday xxx_parent_tables (cost=0.00..25.05 r ows=2 width=324) (actual time=0.011..0.011 rows=0 loops=1) Filter: ((status = 1) OR (status IS NULL)) -> Index Scan using xxx_parent_tables_jobs_monsterindia_creation_time_idx on xxx_parent_tables_jobs_monsterindia xxx_parent_tables (cost=0 .00..31569.68 rows=81849 width=105) (actual time=279.393..544.467 rows=78622 loops=1) Filter: ((status = 1) OR (status IS NULL)) Rows Removed by Filter: 155151 -> Index Scan using xxx_parent_tables_jobs_mprc_creation_time_idx on xxx_parent_tables_jobs_mprc xxx_parent_tables (cost=0.00..25.05 rows= 2 width=324) (actual time=0.016..0.016 rows=0 loops=1) Filter: ((status = 1) OR (status IS NULL)) -> Index Scan using xxx_parent_tables_jobs_myjobsintanzania_creation_time_idx on xxx_parent_tables_jobs_myjobsintanzania xxx_parent_tables (cost=0.00..25.05 rows=2 width=324) (actual time=0.012..0.012 rows=0 loops=1) Filter: ((status = 1) OR (status IS NULL)) -> Index Scan using xxx_parent_tables_mobiles_verse_creation_time_idx on xxx_parent_tables_mobiles_verse xxx_parent_tables (cost=0.00..25. 05 rows=2 width=324) (actual time=0.015..0.015 rows=0 loops=1) Filter: ((status = 1) OR (status IS NULL)) -> Index Scan using xxx_parent_tables_mobileseeker_quikr_creation_time_idx on xxx_parent_tables_mobileseeker_quikr xxx_parent_tables (cost =0.00..13.30 rows=1 width=105) (actual time=0.111..0.111 rows=0 loops=1) Filter: ((status = 1) OR (status IS NULL)) Rows Removed by Filter: 61 Filter: ((status = 1) OR (status IS NULL)) -> Materialize (cost=0.00..3.47 rows=2 width=8) (actual time=0.000..0.000 rows=2 loops=708260) -> Seq Scan on cp_info (cost=0.00..3.46 rows=2 width=8) (actual time=0.028..0.060 rows=2 loops=1) Filter: (domain_id = 5::bigint) Rows Removed by Filter: 115 Total runtime: 70481.560 ms (xxx rows) --047d7b15a99f8bb1e104df045f25 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hi All

One of my query treat= ing performance issue on my production server.
Once i run =A0quer= y on my parent table with specific condition(hard coded value) its uses =A0= only proper child table and its index on explain plan =A0, but once i am us= ing table conditions (instead of hard coded value), query planner is going = all the child tables, Can i know where i am worng=A0

Postgresql version 9.2.2=A0

Pl= ease find details below =A0
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

XXX_db= =3D> select id from xxx where d_id =3D '5';
=A0id=A0
-------
=A0 =A0 =A05
=A0 =A0 45=
(2 rows)


XXX_db=3D> e= xplain =A0analyze =A0SELECT * =A0FROM xxx_parent_table WHERE id in (5,45) a= nd ( sts =3D 1 or status is null ) order by creation_time limit 40 ;
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 QUERY PLAN =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0
=A0
----------= ---------------------------------------------------------------------------= -------------------------------------------------
-
=A0=A0
=A0Limit =A0(cost=3D12.21..12.21 rows=3D3= width=3D251) (actual time=3D6.585..6.585 rows=3D0 loops=3D1)
=A0= =A0-> =A0Sort =A0(cost=3D12.21..12.21 rows=3D3 width=3D251) (actual tim= e=3D6.582..6.582 rows=3D0 loops=3D1)
=A0 =A0 =A0 =A0 =A0Sort Key: public.xxx_parent_tables.creation_time
=A0 =A0 =A0 =A0 =A0Sort Method: quicksort =A0Memory: 25kB
=A0 =A0 =A0 =A0 =A0-> =A0Result =A0(cost=3D0.00..12.18 rows=3D3 width= =3D251) (actual time=3D6.571..6.571 rows=3D0 loops=3D1)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-> =A0Append =A0(cost=3D0.00..12.18 = rows=3D3 width=3D251) (actual time=3D6.569..6.569 rows=3D0 loops=3D1)
=
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-> =A0Seq Scan on xxx_pa= rent_tables =A0(cost=3D0.00..0.00 rows=3D1 width=3D324) (actual time=3D0.00= 3..0.003 rows=3D0 loops=3D1)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Filter: ((id = =3D ANY ('{5,45}'::bigint[])) AND ((status =3D 1) OR (status IS NUL= L)))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-> =A0Bitmap H= eap Scan on xxx_parent_tables_table_details_ xxx_parent_tables =A0(cost=3D4= .52..6.53 rows=3D1 width=3D105) (actual ti
me=3D0.063..0.063 rows=3D0 loops=3D1)
=A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Recheck Cond: ((status =3D 1) OR (status= IS NULL))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0Filter: (id =3D ANY ('{5,45}'::bigint[]))
=A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-> =A0BitmapOr =A0(cost=3D4.5= 2..4.52 rows=3D1 width=3D0) (actual time=3D0.059..0.059 rows=3D0 loops=3D1)=
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-&g= t; =A0Bitmap Index Scan on xxx_parent_tables_table_details__status_idx =A0(= cost=3D0.00..2.26 rows=3D1 width=3D0)
=A0(actual time=3D0.038..0.= 038 rows=3D0 loops=3D1)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Index Cond: (status =3D 1)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-&g= t; =A0Bitmap Index Scan on xxx_parent_tables_table_details__status_idx =A0(= cost=3D0.00..2.26 rows=3D1 width=3D0)
=A0(actual time=3D0.019..0.= 019 rows=3D0 loops=3D1)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Index Cond: (status IS NULL)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-> =A0Bitmap Heap Scan o= n xxx_parent_tables_table_details_det xxx_parent_tables =A0(cost=3D2.52..5.= 65 rows=3D1 width=3D324) (actual ti
me=3D6.502..6.502 rows=3D0 lo= ops=3D1)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0R= echeck Cond: (id =3D ANY ('{5,45}'::bigint[]))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Filter: ((statu= s =3D 1) OR (status IS NULL))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0-> =A0Bitmap Index Scan on xxx_parent_tables_table_d= etails_id_idx =A0(cost=3D0.00..2.52 rows=3D2 width=3D0) (actua
l time=3D6.499..6.499 rows=3D0 loops=3D1)
=A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Index Cond: (id =3D ANY = ('{5,45}'::bigint[]))
=A0Total runtime: 6.823 ms
(22 rows)


XXX_db =3D> explain analyze =A0 =A0SELECT * =A0FROM xxx_parent_tabl= es WHERE cp_id in (select id from xxx where d_id =3D '5') and ( sta= tus =3D 1 or status is null ) order by creation_time limit 40 ;
= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 QUE= RY PLAN =A0 =A0 =A0 =A0 =A0 =A0 =A0
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=A0
-------------= ---------------------------------------------------------------------------= ----------------------------------------------
----------------------------------------------------------------------= --------------------------
=A0Limit =A0(cost=3D3.66..6067.89 rows= =3D40 width=3D105) (actual time=3D70479.596..70479.596 rows=3D0 loops=3D1)<= /div>
=A0 =A0-> =A0Nested Loop Semi Join =A0(cost=3D3.66..4587291.92= rows=3D30258 width=3D105) (actual time=3D70479.593..70479.593 rows=3D0 loo= ps=3D1)
=A0 =A0 =A0 =A0 =A0Join Filter: (public.xxx_parent_tables.cp_id =3D cp= _info.cp_id)
=A0 =A0 =A0 =A0 =A0Rows Removed by Join Filter: 1416= 520
=A0 =A0 =A0 =A0 =A0-> =A0Merge Append =A0(cost=3D3.66..456= 5956.68 rows=3D711059 width=3D105) (actual time=3D67225.964..69635.016 rows= =3D708260 loops=3D1)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Sort Key: public.xxx_parent_tables.crea= tion_time
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-> =A0Sort =A0(cost= =3D0.01..0.02 rows=3D1 width=3D324) (actual time=3D0.018..0.018 rows=3D0 lo= ops=3D1)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Sort Key: pub= lic.xxx_parent_tables.creation_time
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Sort Method: quicksort =A0M= emory: 25kB
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-> =A0S= eq Scan on xxx_parent_tables =A0(cost=3D0.00..0.00 rows=3D1 width=3D324) (a= ctual time=3D0.011..0.011 rows=3D0 loops=3D1)
=A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Filter: ((status =3D 1) OR (status IS N= ULL))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-> =A0Index Scan using xxx_parent_ta= bles_automobiles_carwale_creation_time_idx on xxx_parent_tables_automobiles= _carwale xxx_parent_tables =A0(co
st=3D0.00..649960.44 rows=3D17 = width=3D105) (actual time=3D10219.559..10219.559 rows=3D0 loops=3D1)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Filter: ((status =3D 1) OR = (status IS NULL))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Rows= Removed by Filter: 3102241
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-> = =A0Index Scan using xxx_parent_tables_automobiles_sulekha_creation_time_idx= on xxx_parent_tables_automobiles_sulekha xxx_parent_tables =A0(co
st=3D0.00..1124998.57 rows=3D1 width=3D105) (actual time=3D17817.577..= 17817.577 rows=3D0 loops=3D1)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0Filter: ((status =3D 1) OR (status IS NULL))
=A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Rows Removed by Filter: 4016234
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-> =A0Index Scan using xxx_parent_ta= bles_automobiles_verse_creation_time_idx on xxx_parent_tables_automobiles_v= erse xxx_parent_tables =A0(cost=3D0
.00..24068.88 rows=3D1 width= =3D103) (actual time=3D675.291..675.291 rows=3D0 loops=3D1)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Filter: ((status =3D 1) OR = (status IS NULL))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Rows= Removed by Filter: 420616
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-> = =A0Index Scan using xxx_parent_tables_automobiles_yolist_creation_time_idx = on xxx_parent_tables_automobiles_yolist xxx_parent_tables =A0(cost
=3D0.00..25.05 rows=3D2 width=3D324) (actual time=3D0.016..0.016 rows= =3D0 loops=3D1)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Filter= : ((status =3D 1) OR (status IS NULL))
=A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0-> =A0Index Scan using xxx_parent_tables_deals_bagittoday_creatio= n_time_idx on xxx_parent_tables_deals_bagittoday xxx_parent_tables =A0(cost= =3D0.0
0..23882.78 rows=3D1 width=3D105) (actual time=3D234.672..234.672 rows= =3D0 loops=3D1)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Filter= : ((status =3D 1) OR (status IS NULL))
=A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0Rows Removed by Filter: 84988
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-> =A0Index Scan using xxx_parent_ta= bles_deals_bindaasbargain_creation_time_idx on xxx_parent_tables_deals_bind= aasbargain xxx_parent_tables =A0(
cost=3D0.00..25.05 rows=3D2 wid= th=3D324) (actual time=3D0.016..0.016 rows=3D0 loops=3D1)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Filter: ((status =3D 1) OR = (status IS NULL))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-> =A0Index S= can using xxx_parent_tables_deals_buzzr_creation_time_idx on xxx_parent_tab= les_deals_buzzr xxx_parent_tables =A0(cost=3D0.00..11435.4
1 rows=3D1 width=3D105) (actual time=3D109.466..109.466 rows=3D0 loops= =3D1)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Filter: ((status= =3D 1) OR (status IS NULL))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0Rows Removed by Filter: 33750
=A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0-> =A0Index Scan using xxx_parent_tables_deals_dealdrums_creation_tim= e_idx on xxx_parent_tables_deals_dealdrums xxx_parent_tables =A0(cost=3D0.0= 0.
.51.61 rows=3D1 width=3D105) (actual time=3D0.917..0.917 rows=3D0 loop= s=3D1)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Filter: ((statu= s =3D 1) OR (status IS NULL))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0Rows Removed by Filter: 941
=A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0-> =A0Index Scan using xxx_parent_tables_deals_dealsandyou_creation_t= ime_idx on xxx_parent_tables_deals_dealsandyou xxx_parent_tables =A0(cost= =3D0
.00..25.05 rows=3D2 width=3D324) (actual time=3D0.012..0.012 rows=3D0 = loops=3D1)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Filter: ((s= tatus =3D 1) OR (status IS NULL))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= -> =A0Index Scan using xxx_parent_tables_deals_foodiebay_creation_time_i= dx on xxx_parent_tables_deals_foodiebay xxx_parent_tables =A0(cost=3D0.00.<= /div>
.25.05 rows=3D2 width=3D324) (actual time=3D0.024..0.024 rows=3D0 loop= s=3D1)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Filter: ((statu= s =3D 1) OR (status IS NULL))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0->= ; =A0Index Scan using xxx_parent_tables_deals_futurebazaar_creation_time_id= x on xxx_parent_tables_deals_futurebazaar xxx_parent_tables =A0(cost
=3D0.00..30.37 rows=3D1 width=3D109) (actual time=3D0.348..0.348 rows= =3D0 loops=3D1)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Filter= : ((status =3D 1) OR (status IS NULL))
=A0 =A0
=A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0-> =A0Index Scan using xxx_parent_tables_jobs_job= sa1_creation_time_idx on xxx_parent_tables_jobs_jobsa1 xxx_parent_tables = =A0(cost=3D0.00..25.05 r
ows=3D2 width=3D324) (actual time=3D0.020..0.020 rows=3D0 loops=3D1)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Filter: ((status =3D 1)= OR (status IS NULL))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-> =A0Ind= ex Scan using xxx_parent_tables_jobs_jobsinnigeria_creation_time_idx on xxx= _parent_tables_jobs_jobsinnigeria xxx_parent_tables =A0(cost
=3D0.00..25.05 rows=3D2 width=3D324) (actual time=3D0.013..0.013 rows= =3D0 loops=3D1)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Filter= : ((status =3D 1) OR (status IS NULL))
=A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0-> =A0Index Scan using xxx_parent_tables_jobs_khojle_creation_tim= e_idx on xxx_parent_tables_jobs_khojle xxx_parent_tables =A0(cost=3D0.00..2= 5.05 r
ows=3D2 width=3D324) (actual time=3D0.013..0.013 rows=3D0 loops=3D1)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Filter: ((status =3D 1)= OR (status IS NULL))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-> =A0Ind= ex Scan using xxx_parent_tables_jobs_midday_creation_time_idx on xxx_parent= _tables_jobs_midday xxx_parent_tables =A0(cost=3D0.00..25.05 r
ows=3D2 width=3D324) (actual time=3D0.011..0.011 rows=3D0 loops=3D1)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Filter: ((status =3D 1)= OR (status IS NULL))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-> =A0Ind= ex Scan using xxx_parent_tables_jobs_monsterindia_creation_time_idx on xxx_= parent_tables_jobs_monsterindia xxx_parent_tables =A0(cost=3D0
.00..31569.68 rows=3D81849 width=3D105) (actual time=3D279.393..544.46= 7 rows=3D78622 loops=3D1)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0Filter: ((status =3D 1) OR (status IS NULL))
=A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0Rows Removed by Filter: 155151
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-> =A0Index Scan using xxx_parent_ta= bles_jobs_mprc_creation_time_idx on xxx_parent_tables_jobs_mprc xxx_parent_= tables =A0(cost=3D0.00..25.05 rows=3D
2 width=3D324) (actual time= =3D0.016..0.016 rows=3D0 loops=3D1)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Filter: ((status =3D 1) OR = (status IS NULL))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-> =A0Index S= can using xxx_parent_tables_jobs_myjobsintanzania_creation_time_idx on xxx_= parent_tables_jobs_myjobsintanzania xxx_parent_tables=A0
=A0(cost=3D0.00..25.05 rows=3D2 width=3D324) (actual time=3D0.012..0.0= 12 rows=3D0 loops=3D1)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0Filter: ((status =3D 1) OR (status IS NULL))
=A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 -> =A0Index Scan using xxx_parent_tables_mob= iles_verse_creation_time_idx on xxx_parent_tables_mobiles_verse xxx_parent_= tables =A0(cost=3D0.00..25.
05 rows=3D2 width=3D324) (actual time=3D0.015..0.015 rows=3D0 loops=3D= 1)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Filter: ((status = =3D 1) OR (status IS NULL))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-> = =A0Index Scan using xxx_parent_tables_mobileseeker_quikr_creation_time_idx = on xxx_parent_tables_mobileseeker_quikr xxx_parent_tables =A0(cost
=3D0.00..13.30 rows=3D1 width=3D105) (actual time=3D0.111..0.111 rows= =3D0 loops=3D1)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Filter= : ((status =3D 1) OR (status IS NULL))
=A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0Rows Removed by Filter: 61
=A0 =A0=A0
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Filter: ((status =3D 1) OR = (status IS NULL))
=A0 =A0 =A0 =A0 =A0-> =A0Materialize =A0(cos= t=3D0.00..3.47 rows=3D2 width=3D8) (actual time=3D0.000..0.000 rows=3D2 loo= ps=3D708260)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-> =A0Seq Scan on = cp_info =A0(cost=3D0.00..3.46 rows=3D2 width=3D8) (actual time=3D0.028..0.0= 60 rows=3D2 loops=3D1)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Filter: (domain_id =3D 5::b= igint)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Rows Removed by= Filter: 115
=A0Total runtime: 70481.560 ms
(xxx rows)<= /div>
--047d7b15a99f8bb1e104df045f25-- From gray.ru@gmail.com Thu Jun 13 09:04:20 2013 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Un3S8-0005lC-2n for pgsql-performance@arkaria.postgresql.org; Thu, 13 Jun 2013 09:04:20 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Un3S7-0005yE-GG for pgsql-performance@arkaria.postgresql.org; Thu, 13 Jun 2013 09:04:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Un3S6-0005y7-DK for pgsql-performance@postgresql.org; Thu, 13 Jun 2013 09:04:18 +0000 Received: from mail-pd0-f179.google.com ([209.85.192.179]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Un3Rt-0003ce-C4 for pgsql-performance@postgresql.org; Thu, 13 Jun 2013 09:04:17 +0000 Received: by mail-pd0-f179.google.com with SMTP id q10so5161331pdj.38 for ; Thu, 13 Jun 2013 02:04:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=mLWhVj2tKPpFnxN7WDn5TjkKrFLwrD07MZ+9YY7ryYo=; b=zqCWCLDyuSA+YxMpX41xlnq8EOeVo5T6uQTqe+LTRbyHGk0wo6hbvwmVeyUfZMISqf ZijS6AsG9b7kunm9xqNoPk4okq3mtUcUQy8aTzZ0OFyj+3N95MriBFKZo7tlkhVKuj61 Wh6d8OH+l8n+h/bj5YoRCg0OQTqD+L1m75glMkkGbua5VIl+wyDc64h2PjPL+u2utZHI DBu/w/+LP8MiWiUHmzMbB6ufsWmjdxkXiEjqsbDfqEeXnX+bt4w/lSKERvl/M4TL+f4o nWjlolKUJmam01aIJ5W7NV2nktPQcgvzFHUyBKqomP8UlHCI45hS3EWUZvUiiPEQnNyy JBfw== X-Received: by 10.68.226.39 with SMTP id rp7mr23520597pbc.97.1371114243317; Thu, 13 Jun 2013 02:04:03 -0700 (PDT) MIME-Version: 1.0 Received: by 10.68.80.234 with HTTP; Thu, 13 Jun 2013 02:03:43 -0700 (PDT) In-Reply-To: References: From: Sergey Konoplev Date: Thu, 13 Jun 2013 02:03:43 -0700 Message-ID: Subject: Re: Query performance To: K P Manoj Cc: "pgsql-performance@postgresql.org" Content-Type: text/plain; charset=ISO-8859-1 X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org On Thu, Jun 13, 2013 at 12:49 AM, K P Manoj wrote: > One of my query treating performance issue on my production server. > Once i run query on my parent table with specific condition(hard coded > value) its uses only proper child table and its index on explain plan , > but once i am using table conditions (instead of hard coded value), query > planner is going all the child tables, Can i know where i am worng From joe@tanga.com Sun Jan 25 05:42:05 2015 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YFFxV-0001DG-L1 for pgsql-performance@arkaria.postgresql.org; Sun, 25 Jan 2015 05:42:05 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YFFxV-0000Fj-5O for pgsql-performance@arkaria.postgresql.org; Sun, 25 Jan 2015 05:42:05 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YFFxT-0000Fc-LP for pgsql-performance@postgresql.org; Sun, 25 Jan 2015 05:42:04 +0000 Received: from mail-qa0-x230.google.com ([2607:f8b0:400d:c00::230]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YFFxL-0007P8-8i for pgsql-performance@postgresql.org; Sun, 25 Jan 2015 05:42:01 +0000 Received: by mail-qa0-f48.google.com with SMTP id v8so3176026qal.7 for ; Sat, 24 Jan 2015 21:41:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:from:date:message-id:subject:to:content-type; bh=eOCcjrkK+2LLP7/aJ5Jw7yoSRBfC7mr5nAEw99f33gE=; b=CJn2QCxPkMLfK+3DymE+c3sIyXEgghYK5iCqvpGN3rgMc5QoHnaE9YjJbUb8JOMf90 3VugGS1enFPfCyBcS0S8XNovA5o8xTAz4B0uYG3gJ3jBSQPfvnz7wucSqhMuY9Myn8IY 2eT4snZ6RHa7WHsQ1YLAqqqVJI2V4Cy6xfiryOjvep7t3/Rq02/1UQd0O7CYhzdiI2eY 9Zq/UQ9Yj5t0Wkykqw+cdudlELPNCC9/z8G0T+6tF2RTsAhmPCDeb4Onnd6/qvu7y0w/ mcGE3M1osasv+/Z3RN85Ki9FgFoA2L/mFJYd9BV9Tro0Zc1ifBxX6nfWWMCB5a7G3LiL JkrQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tanga.com; s=google; h=mime-version:sender:from:date:message-id:subject:to:content-type; bh=eOCcjrkK+2LLP7/aJ5Jw7yoSRBfC7mr5nAEw99f33gE=; b=NPO6vxlGQ1K5lUcm8IO8LLwFc+5pqwJot625ZIJAXCa9FQ/kK4He+lxRO/GPtzcT36 BFy9cgjBorWgoSCDmUFDmQeDqi1/De3Nu/GL++lId/jy85UnbIiEqLCHOcbQCwGbnwrD uOdU/uj3tLuQhkqTsj9r9cYLUb3+4oziGuK6k= X-Received: by 10.140.49.5 with SMTP id p5mr28923638qga.15.1422164513886; Sat, 24 Jan 2015 21:41:53 -0800 (PST) MIME-Version: 1.0 Received: by 10.140.240.23 with HTTP; Sat, 24 Jan 2015 21:41:13 -0800 (PST) From: Joe Van Dyk Date: Sat, 24 Jan 2015 21:41:13 -0800 X-Google-Sender-Auth: _S9Jwjs4PG9yRYa38WphCfjG-0c Message-ID: Subject: Query performance To: "pgsql-performance@postgresql.org" Content-Type: multipart/alternative; boundary=001a11351944a9b855050d737a64 X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org --001a11351944a9b855050d737a64 Content-Type: text/plain; charset=UTF-8 I have an events table that records page views and purchases (type = 'viewed' or type='purchased'). I have a query that figures out "people who bought/viewed this also bought/viewed that". It worked fine, taking about 0.1 seconds to complete, until a few hours ago when it started taking hours to complete. Vacuum/analyze didn't help. Turned out there was one session_id that had 400k rows in the system. Deleting that made the query performant again. Is there anything I can do to make the query work better in cases like that? Missing index, or better query? This is on 9.3.5. The below is reproduced at the following URL if it's not formatted correctly in the email. https://gist.githubusercontent.com/joevandyk/cb8f4afdb6c1b178c606/raw/9940bbe033ebd56d38caa46e33c1ddfd9df36eda/gistfile1.txt explain select e1.product_id, e2.site_id, e2.product_id, count(nullif(e2.type='viewed', false)) view_count, count(nullif(e2.type='purchased', false)) purchase_count from events e1 join events e2 on e1.session_id = e2.session_id and e1.type = e2.type where e1.product_id = '82503' and e1.product_id != e2.product_id group by e1.product_id, e2.product_id, e2.site_id; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------- GroupAggregate (cost=828395.67..945838.90 rows=22110 width=19) -> Sort (cost=828395.67..840117.89 rows=4688885 width=19) Sort Key: e1.product_id, e2.product_id, e2.site_id -> Nested Loop (cost=11.85..20371.14 rows=4688885 width=19) -> Bitmap Heap Scan on events e1 (cost=11.29..1404.31 rows=369 width=49) Recheck Cond: (product_id = '82503'::citext) -> Bitmap Index Scan on events_product_id_site_id_idx (cost=0.00..11.20 rows=369 width=0) Index Cond: (product_id = '82503'::citext) -> Index Scan using events_session_id_type_product_id_idx on events e2 (cost=0.56..51.28 rows=12 width=51) Index Cond: ((session_id = e1.session_id) AND (type = e1.type)) Filter: (e1.product_id <> product_id) (11 rows) recommender_production=> \d events Table "public.events" Column | Type | Modifiers -------------+--------------------------+----------------------------------------------------- id | bigint | not null default nextval('events_id_seq'::regclass) user_id | citext | session_id | citext | not null product_id | citext | not null site_id | citext | not null type | text | not null happened_at | timestamp with time zone | not null created_at | timestamp with time zone | not null Indexes: "events_pkey" PRIMARY KEY, btree (id) "events_product_id_site_id_idx" btree (product_id, site_id) "events_session_id_type_product_id_idx" btree (session_id, type, product_id) Check constraints: "events_session_id_check" CHECK (length(session_id::text) < 255) "events_type_check" CHECK (type = ANY (ARRAY['purchased'::text, 'viewed'::text])) "events_user_id_check" CHECK (length(user_id::text) < 255) --001a11351944a9b855050d737a64 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I have an events table that records page views and pu= rchases (type =3D 'viewed' or type=3D'purchased'). I have a= query that figures out "people who bought/viewed this also bought/vie= wed that".

It worked fine, taking about 0.1 s= econds to complete, until a few hours ago when it started taking hours to c= omplete. Vacuum/analyze didn't help.=C2=A0 Turned out there was one ses= sion_id that had 400k rows in the system. Deleting that made the query perf= ormant again.=C2=A0

Is there anything I can do to = make the query work better in cases like that? Missing index, or better que= ry?

This is on 9.3.5.

The belo= w is reproduced at the following URL if it's not formatted correctly in= the email. h= ttps://gist.githubusercontent.com/joevandyk/cb8f4afdb6c1b178c606/raw/9940bb= e033ebd56d38caa46e33c1ddfd9df36eda/gistfile1.txt

explain select e1.product_id, e2.site_id, e2.product_id, count(nullif(e2.type=3D'viewed', false)) view_count, count(nullif(e2.type=3D'purchased', false)) purchase_count from events e1 join events e2 on e1.session_id =3D e2.session_id and e1.type =3D e2.type where e1.product_id =3D '82503' and e1.product_id !=3D e2.product_id group by e1.product_id, e2.product_id, e2.site_id; QUERY PLAN ---------------------------------------------------------------------------= ------------------------------------------------- GroupAggregate (cost=3D828395.67..945838.90 rows=3D22110 width=3D19) -> Sort (cost=3D828395.67..840117.89 rows=3D4688885 width=3D19) Sort Key: e1.product_id, e2.product_id, e2.site_id -> Nested Loop (cost=3D11.85..20371.14 rows=3D4688885 width= =3D19) -> Bitmap Heap Scan on events e1 (cost=3D11.29..1404.31= rows=3D369 width=3D49) Recheck Cond: (product_id =3D '82503'::citext) -> Bitmap Index Scan on events_product_id_site_id_= idx (cost=3D0.00..11.20 rows=3D369 width=3D0) Index Cond: (product_id =3D '82503'::cit= ext) -> Index Scan using events_session_id_type_product_id_id= x on events e2 (cost=3D0.56..51.28 rows=3D12 width=3D51) Index Cond: ((session_id =3D e1.session_id) AND (type = =3D e1.type)) Filter: (e1.product_id <> product_id) (11 rows) recommender_production=3D> \d events Table "public.events" Column | Type | Modifiers -------------+--------------------------+----------------------------------= ------------------- id | bigint | not null default nextval('eve= nts_id_seq'::regclass) user_id | citext | session_id | citext | not null product_id | citext | not null site_id | citext | not null type | text | not null happened_at | timestamp with time zone | not null created_at | timestamp with time zone | not null Indexes: "events_pkey" PRIMARY KEY, btree (id) "events_product_id_site_id_idx" btree (product_id, site_id) "events_session_id_type_product_id_idx" btree (session_id, ty= pe, product_id) Check constraints: "events_session_id_check" CHECK (length(session_id::text) <= ; 255) "events_type_check" CHECK (type =3D ANY (ARRAY['purchased= '::text, 'viewed'::text])) "events_user_id_check" CHECK (length(user_id::text) < 255)=


--001a11351944a9b855050d737a64-- From joe@tanga.com Sun Jan 25 05:44:03 2015 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YFFzP-0001FO-SO for pgsql-performance@arkaria.postgresql.org; Sun, 25 Jan 2015 05:44:03 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YFFzP-0001rk-9t for pgsql-performance@arkaria.postgresql.org; Sun, 25 Jan 2015 05:44:03 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YFFzN-0001p3-Ha for pgsql-performance@postgresql.org; Sun, 25 Jan 2015 05:44:01 +0000 Received: from mail-qg0-x235.google.com ([2607:f8b0:400d:c04::235]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YFFzJ-0007Pg-VJ for pgsql-performance@postgresql.org; Sun, 25 Jan 2015 05:43:59 +0000 Received: by mail-qg0-f53.google.com with SMTP id a108so3181997qge.12 for ; Sat, 24 Jan 2015 21:43:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=LjtN/q+6NwVO7Xd+as4oal8yxCKwig2QAgxU8DjjwA4=; b=M0TBz5nyjdrGUXFATvVPBkU6f5doObVLijqknU5TLTbfON9c+T/DS20z7IG8wFrekd Bbej4ML8DxRnhHgc9apRc9MwzNYjCaWRef5OvNBjnG/u2oc0V/JzaP+FwgvPOG19NmBN QGXcduN9Xa0O4Ld4VWR5AmqpHLnTq28maRQbOoJg3KnmUdu3CV9vulYDO89lIC9N0K8W 339VM4mKnnz1WmB20mH0JR+6A6zFxf7O+ui2FqditpM4zVPFeLaYacVIG0ZP6jE8vJ8N 9+Bzf5eqsak8padzcIhIhXJbK+w2XAzBhzH+C4CIx3M2wyevjqSs3rF33Q41g7Q2zJ84 hZ4Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tanga.com; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=LjtN/q+6NwVO7Xd+as4oal8yxCKwig2QAgxU8DjjwA4=; b=OOdHEWpFhC+fGjZv31nUIrUdqvvPQaMk9SCJP4GCzR2c8gBKnDMcu2yDNhL0XjpqV5 plsH+/JUENdGDFQUAja28DwJ1edi1hFXlaO4Qja7SOEACbtBgLsKjGbFm2HcVEe5zY3/ wHtq/NcILoqiUjnOqJ1wy7M9OkblhXFkFYPnk= X-Received: by 10.229.50.135 with SMTP id z7mr11984328qcf.21.1422164637320; Sat, 24 Jan 2015 21:43:57 -0800 (PST) MIME-Version: 1.0 Received: by 10.140.240.23 with HTTP; Sat, 24 Jan 2015 21:43:17 -0800 (PST) In-Reply-To: References: From: Joe Van Dyk Date: Sat, 24 Jan 2015 21:43:17 -0800 X-Google-Sender-Auth: gEkCs9DnGP9pLL7MkqrL3SdiJX4 Message-ID: Subject: Re: Query performance To: "pgsql-performance@postgresql.org" Content-Type: multipart/alternative; boundary=001a11341e5c050e00050d7382bb X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org --001a11341e5c050e00050d7382bb Content-Type: text/plain; charset=UTF-8 On Sat, Jan 24, 2015 at 9:41 PM, Joe Van Dyk wrote: > I have an events table that records page views and purchases (type = > 'viewed' or type='purchased'). I have a query that figures out "people who > bought/viewed this also bought/viewed that". > > It worked fine, taking about 0.1 seconds to complete, until a few hours > ago when it started taking hours to complete. Vacuum/analyze didn't help. > Turned out there was one session_id that had 400k rows in the system. > Deleting that made the query performant again. > > Is there anything I can do to make the query work better in cases like > that? Missing index, or better query? > > This is on 9.3.5. > > The below is reproduced at the following URL if it's not formatted > correctly in the email. > https://gist.githubusercontent.com/joevandyk/cb8f4afdb6c1b178c606/raw/9940bbe033ebd56d38caa46e33c1ddfd9df36eda/gistfile1.txt > > explain select > e1.product_id, > e2.site_id, > e2.product_id, > count(nullif(e2.type='viewed', false)) view_count, > count(nullif(e2.type='purchased', false)) purchase_count > from events e1 > join events e2 on e1.session_id = e2.session_id and e1.type = e2.type > where > e1.product_id = '82503' and > e1.product_id != e2.product_id > group by e1.product_id, e2.product_id, e2.site_id; > QUERY PLAN > ---------------------------------------------------------------------------------------------------------------------------- > GroupAggregate (cost=828395.67..945838.90 rows=22110 width=19) > -> Sort (cost=828395.67..840117.89 rows=4688885 width=19) > Sort Key: e1.product_id, e2.product_id, e2.site_id > -> Nested Loop (cost=11.85..20371.14 rows=4688885 width=19) > -> Bitmap Heap Scan on events e1 (cost=11.29..1404.31 rows=369 width=49) > Recheck Cond: (product_id = '82503'::citext) > -> Bitmap Index Scan on events_product_id_site_id_idx (cost=0.00..11.20 rows=369 width=0) > Index Cond: (product_id = '82503'::citext) > -> Index Scan using events_session_id_type_product_id_idx on events e2 (cost=0.56..51.28 rows=12 width=51) > Index Cond: ((session_id = e1.session_id) AND (type = e1.type)) > Filter: (e1.product_id <> product_id) > (11 rows) > > recommender_production=> \d events > Table "public.events" > Column | Type | Modifiers > -------------+--------------------------+----------------------------------------------------- > id | bigint | not null default nextval('events_id_seq'::regclass) > user_id | citext | > session_id | citext | not null > product_id | citext | not null > site_id | citext | not null > type | text | not null > happened_at | timestamp with time zone | not null > created_at | timestamp with time zone | not null > Indexes: > "events_pkey" PRIMARY KEY, btree (id) > "events_product_id_site_id_idx" btree (product_id, site_id) > "events_session_id_type_product_id_idx" btree (session_id, type, product_id) > Check constraints: > "events_session_id_check" CHECK (length(session_id::text) < 255) > "events_type_check" CHECK (type = ANY (ARRAY['purchased'::text, 'viewed'::text])) > "events_user_id_check" CHECK (length(user_id::text) < 255) > > > > After removing the session with 400k events, I was able to do an explain analyze, here is one of them: http://explain.depesz.com/s/PFNk --001a11341e5c050e00050d7382bb Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On S= at, Jan 24, 2015 at 9:41 PM, Joe Van Dyk <joe@tanga.com> wrote:<= br>
I have an events table that recor= ds page views and purchases (type =3D 'viewed' or type=3D'purch= ased'). I have a query that figures out "people who bought/viewed = this also bought/viewed that".

It worked fine= , taking about 0.1 seconds to complete, until a few hours ago when it start= ed taking hours to complete. Vacuum/analyze didn't help.=C2=A0 Turned o= ut there was one session_id that had 400k rows in the system. Deleting that= made the query performant again.=C2=A0

Is there a= nything I can do to make the query work better in cases like that? Missing = index, or better query?

This is on 9.3.5.

The below is reproduced at the following URL if it's not fo= rmatted correctly in the email. https://gist.githubusercontent.com/joe= vandyk/cb8f4afdb6c1b178c606/raw/9940bbe033ebd56d38caa46e33c1ddfd9df36eda/gi= stfile1.txt

explain  select
   e1.product_id,
   e2.site_id,
   e2.product_id,
   count(nullif(e2.type=3D'viewed', false)) view_count,
   count(nullif(e2.type=3D'purchased', false)) purchase_count
 from events e1
 join events e2 on e1.session_id =3D e2.session_id and e1.type =3D e2.type
 where
   e1.product_id =3D '82503' and
   e1.product_id !=3D e2.product_id
 group by e1.product_id, e2.product_id, e2.site_id;
                                                         QUERY PLAN
---------------------------------------------------------------------------=
-------------------------------------------------
 GroupAggregate  (cost=3D828395.67..945838.90 rows=3D22110 width=3D19)
   ->  Sort  (cost=3D828395.67..840117.89 rows=3D4688885 width=3D19)
         Sort Key: e1.product_id, e2.product_id, e2.site_id
         ->  Nested Loop  (cost=3D11.85..20371.14 rows=3D4688885 width=
=3D19)
               ->  Bitmap Heap Scan on events e1  (cost=3D11.29..1404.31=
 rows=3D369 width=3D49)
                     Recheck Cond: (product_id =3D '82503'::citext)
                     ->  Bitmap Index Scan on events_product_id_site_id_=
idx  (cost=3D0.00..11.20 rows=3D369 width=3D0)
                           Index Cond: (product_id =3D '82503'::cit=
ext)
               ->  Index Scan using events_session_id_type_product_id_id=
x on events e2  (cost=3D0.56..51.28 rows=3D12 width=3D51)
                     Index Cond: ((session_id =3D e1.session_id) AND (type =
=3D e1.type))
                     Filter: (e1.product_id <> product_id)
(11 rows)

recommender_production=3D> \d events
                                    Table "public.events"
   Column    |           Type           |                      Modifiers
-------------+--------------------------+----------------------------------=
-------------------
 id          | bigint                   | not null default nextval('eve=
nts_id_seq'::regclass)
 user_id     | citext                   |
 session_id  | citext                   | not null
 product_id  | citext                   | not null
 site_id     | citext                   | not null
 type        | text                     | not null
 happened_at | timestamp with time zone | not null
 created_at  | timestamp with time zone | not null
Indexes:
    "events_pkey" PRIMARY KEY, btree (id)
    "events_product_id_site_id_idx" btree (product_id, site_id)
    "events_session_id_type_product_id_idx" btree (session_id, ty=
pe, product_id)
Check constraints:
    "events_session_id_check" CHECK (length(session_id::text) <=
; 255)
    "events_type_check" CHECK (type =3D ANY (ARRAY['purchased=
'::text, 'viewed'::text]))
    "events_user_id_check" CHECK (length(user_id::text) < 255)=



After removing the = session with 400k events, I was able to do an explain analyze, here is one = of them:
--001a11341e5c050e00050d7382bb-- From joe@tanga.com Sun Jan 25 05:46:40 2015 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YFG1w-0001MO-JS for pgsql-performance@arkaria.postgresql.org; Sun, 25 Jan 2015 05:46:40 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YFG1v-0003yh-Ig for pgsql-performance@arkaria.postgresql.org; Sun, 25 Jan 2015 05:46:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YFG1u-0003yb-Op for pgsql-performance@postgresql.org; Sun, 25 Jan 2015 05:46:38 +0000 Received: from mail-qc0-x229.google.com ([2607:f8b0:400d:c01::229]) by magus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YFG1p-0008Bu-W8 for pgsql-performance@postgresql.org; Sun, 25 Jan 2015 05:46:37 +0000 Received: by mail-qc0-f169.google.com with SMTP id b13so3272461qcw.0 for ; Sat, 24 Jan 2015 21:46:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=lbpoLMqvE97pWtrOT2zCtz4v270H6OyQBpnARHIasEQ=; b=bqaxa54yJjEYr6XhB/KnEDoY3NuX8J+U4yxwT+TRlt585rGd6IV8ZtcdMjqx6BB2dG pW1VqhUfRrPviJnmGZXzEHWin4srZ84HyDGsocSPYqAhfBQZFSeoInabxu78PqvhKFIm vXvLjJFqSC6eFAAM3x7A14czP0Tm/MS+gf8qEEoCyhiZZzTPzvMLgU8C0LQpjexHDm/t UhvyczDEU2Q58Ak8PRjdap7/7/Ljm4Af4nTQsiuKuM/tmXsJdJbIXptHgtAeaNRgS5pt KT0OpHLADGEE6hKqH+IEsPPFodXMhZI7fEQ9qytTITk7yafmb8ys3SOiDF7AVUltxIZ9 Pn7g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tanga.com; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=lbpoLMqvE97pWtrOT2zCtz4v270H6OyQBpnARHIasEQ=; b=jhn5Qoim404Zn0tRCjRzz6iZjyWwKE6jPDdGrBrbC8Tjc96CGsfrvLiLuLvC+HckWh lWYBcQGF7+y06RVuW3sBCU/qCDPHiFXU0yzF7Zg+Tz90IiLV4ebOrmaMvjMQYd2QQULK CKWbQBGD7QnCXUkjN8uIETdM5Wt1RG3or9ork= X-Received: by 10.224.75.71 with SMTP id x7mr4326489qaj.90.1422164790889; Sat, 24 Jan 2015 21:46:30 -0800 (PST) MIME-Version: 1.0 Received: by 10.140.240.23 with HTTP; Sat, 24 Jan 2015 21:45:50 -0800 (PST) In-Reply-To: References: From: Joe Van Dyk Date: Sat, 24 Jan 2015 21:45:50 -0800 X-Google-Sender-Auth: zIKNSA0p4P-U-4jmxh4vlYOJQrg Message-ID: Subject: Re: Query performance To: "pgsql-performance@postgresql.org" Content-Type: multipart/alternative; boundary=001a11c304b22c5412050d738b5d X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org --001a11c304b22c5412050d738b5d Content-Type: text/plain; charset=UTF-8 Oops, didn't run vacuum analyze after deleting the events. Here is another 'explain analyze': http://explain.depesz.com/s/AviN On Sat, Jan 24, 2015 at 9:43 PM, Joe Van Dyk wrote: > On Sat, Jan 24, 2015 at 9:41 PM, Joe Van Dyk wrote: > >> I have an events table that records page views and purchases (type = >> 'viewed' or type='purchased'). I have a query that figures out "people who >> bought/viewed this also bought/viewed that". >> >> It worked fine, taking about 0.1 seconds to complete, until a few hours >> ago when it started taking hours to complete. Vacuum/analyze didn't help. >> Turned out there was one session_id that had 400k rows in the system. >> Deleting that made the query performant again. >> >> Is there anything I can do to make the query work better in cases like >> that? Missing index, or better query? >> >> This is on 9.3.5. >> >> The below is reproduced at the following URL if it's not formatted >> correctly in the email. >> https://gist.githubusercontent.com/joevandyk/cb8f4afdb6c1b178c606/raw/9940bbe033ebd56d38caa46e33c1ddfd9df36eda/gistfile1.txt >> >> explain select >> e1.product_id, >> e2.site_id, >> e2.product_id, >> count(nullif(e2.type='viewed', false)) view_count, >> count(nullif(e2.type='purchased', false)) purchase_count >> from events e1 >> join events e2 on e1.session_id = e2.session_id and e1.type = e2.type >> where >> e1.product_id = '82503' and >> e1.product_id != e2.product_id >> group by e1.product_id, e2.product_id, e2.site_id; >> QUERY PLAN >> ---------------------------------------------------------------------------------------------------------------------------- >> GroupAggregate (cost=828395.67..945838.90 rows=22110 width=19) >> -> Sort (cost=828395.67..840117.89 rows=4688885 width=19) >> Sort Key: e1.product_id, e2.product_id, e2.site_id >> -> Nested Loop (cost=11.85..20371.14 rows=4688885 width=19) >> -> Bitmap Heap Scan on events e1 (cost=11.29..1404.31 rows=369 width=49) >> Recheck Cond: (product_id = '82503'::citext) >> -> Bitmap Index Scan on events_product_id_site_id_idx (cost=0.00..11.20 rows=369 width=0) >> Index Cond: (product_id = '82503'::citext) >> -> Index Scan using events_session_id_type_product_id_idx on events e2 (cost=0.56..51.28 rows=12 width=51) >> Index Cond: ((session_id = e1.session_id) AND (type = e1.type)) >> Filter: (e1.product_id <> product_id) >> (11 rows) >> >> recommender_production=> \d events >> Table "public.events" >> Column | Type | Modifiers >> -------------+--------------------------+----------------------------------------------------- >> id | bigint | not null default nextval('events_id_seq'::regclass) >> user_id | citext | >> session_id | citext | not null >> product_id | citext | not null >> site_id | citext | not null >> type | text | not null >> happened_at | timestamp with time zone | not null >> created_at | timestamp with time zone | not null >> Indexes: >> "events_pkey" PRIMARY KEY, btree (id) >> "events_product_id_site_id_idx" btree (product_id, site_id) >> "events_session_id_type_product_id_idx" btree (session_id, type, product_id) >> Check constraints: >> "events_session_id_check" CHECK (length(session_id::text) < 255) >> "events_type_check" CHECK (type = ANY (ARRAY['purchased'::text, 'viewed'::text])) >> "events_user_id_check" CHECK (length(user_id::text) < 255) >> >> >> >> > After removing the session with 400k events, I was able to do an explain > analyze, here is one of them: > http://explain.depesz.com/s/PFNk > --001a11c304b22c5412050d738b5d Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Oops, didn't run vacuum analyze after deleting the eve= nts. Here is another 'explain analyze':=C2=A0http://explain.depesz.com/s/AviN

On Sat, Jan 24, 2015 at= 9:43 PM, Joe Van Dyk <joe@tanga.com> wrote:
On Sat, Jan 24, 2015 at 9:41 PM, Joe Van = Dyk <joe@tanga.com> wrote:
=
I have an events table that records page views and purchases (type =3D= 'viewed' or type=3D'purchased'). I have a query that figur= es out "people who bought/viewed this also bought/viewed that".

It worked fine, taking about 0.1 seconds to complet= e, until a few hours ago when it started taking hours to complete. Vacuum/a= nalyze didn't help.=C2=A0 Turned out there was one session_id that had = 400k rows in the system. Deleting that made the query performant again.=C2= =A0

Is there anything I can do to make the query w= ork better in cases like that? Missing index, or better query?
This is on 9.3.5.

The below is reproduced = at the following URL if it's not formatted correctly in the email. https://gist.githubusercontent.com/joevandyk/cb8f4afdb6c1b178c606/raw/9940= bbe033ebd56d38caa46e33c1ddfd9df36eda/gistfile1.txt

<= pre style=3D"color:rgb(0,0,0);word-wrap:break-word;white-space:pre-wrap">explain select e1.product_id, e2.site_id, e2.product_id, count(nullif(e2.type=3D'viewed', false)) view_count, count(nullif(e2.type=3D'purchased', false)) purchase_count from events e1 join events e2 on e1.session_id =3D e2.session_id and e1.type =3D e2.type where e1.product_id =3D '82503' and e1.product_id !=3D e2.product_id group by e1.product_id, e2.product_id, e2.site_id; QUERY PLAN ---------------------------------------------------------------------------= ------------------------------------------------- GroupAggregate (cost=3D828395.67..945838.90 rows=3D22110 width=3D19) -> Sort (cost=3D828395.67..840117.89 rows=3D4688885 width=3D19) Sort Key: e1.product_id, e2.product_id, e2.site_id -> Nested Loop (cost=3D11.85..20371.14 rows=3D4688885 width= =3D19) -> Bitmap Heap Scan on events e1 (cost=3D11.29..1404.31= rows=3D369 width=3D49) Recheck Cond: (product_id =3D '82503'::citext) -> Bitmap Index Scan on events_product_id_site_id_= idx (cost=3D0.00..11.20 rows=3D369 width=3D0) Index Cond: (product_id =3D '82503'::cit= ext) -> Index Scan using events_session_id_type_product_id_id= x on events e2 (cost=3D0.56..51.28 rows=3D12 width=3D51) Index Cond: ((session_id =3D e1.session_id) AND (type = =3D e1.type)) Filter: (e1.product_id <> product_id) (11 rows) recommender_production=3D> \d events Table "public.events" Column | Type | Modifiers -------------+--------------------------+----------------------------------= ------------------- id | bigint | not null default nextval('eve= nts_id_seq'::regclass) user_id | citext | session_id | citext | not null product_id | citext | not null site_id | citext | not null type | text | not null happened_at | timestamp with time zone | not null created_at | timestamp with time zone | not null Indexes: "events_pkey" PRIMARY KEY, btree (id) "events_product_id_site_id_idx" btree (product_id, site_id) "events_session_id_type_product_id_idx" btree (session_id, ty= pe, product_id) Check constraints: "events_session_id_check" CHECK (length(session_id::text) <= ; 255) "events_type_check" CHECK (type =3D ANY (ARRAY['purchased= '::text, 'viewed'::text])) "events_user_id_check" CHECK (length(user_id::text) < 255)=



After r= emoving the session with 400k events, I was able to do an explain analyze, = here is one of them:

--001a11c304b22c5412050d738b5d-- From pavel.stehule@gmail.com Sun Jan 25 06:13:00 2015 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YFGRQ-0002Ed-LJ for pgsql-performance@arkaria.postgresql.org; Sun, 25 Jan 2015 06:13:00 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YFGRP-0006Ob-VS for pgsql-performance@arkaria.postgresql.org; Sun, 25 Jan 2015 06:13:00 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YFGRN-0006OS-Be for pgsql-performance@postgresql.org; Sun, 25 Jan 2015 06:12:57 +0000 Received: from mail-pd0-x22f.google.com ([2607:f8b0:400e:c02::22f]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YFGRJ-0007yi-J4 for pgsql-performance@postgresql.org; Sun, 25 Jan 2015 06:12:55 +0000 Received: by mail-pd0-f175.google.com with SMTP id fl12so5898623pdb.6 for ; Sat, 24 Jan 2015 22:12:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=PCcdj7dG7it6iPK+pnbMrDVFOSpMUDA43c0mx9Nb4Ho=; b=ETk0J3lOp6lzAVRy6RmAdXTcXcstFWMIorlyZz7stbeusVgMQ3IwjKEtmmZIXDZyML Z0qyPZhukLls4to32jhrA+3SrMQUREDMvVdsO2cOx73lUZYQ3v/8bAtPL8FFfxrXwV7U 0HjjYaagICg15nUAdGJkGD6NFJo/bDz/ZaCIEypk2OjYRQah+fuF1JtMUaZjXd0qlu+h sYa3l7KwIt9E8iKTO8MfoVWLnMVdxlsr/HR2o46Lb8r4M0cdM2/7X2GpuRyHnxry0m9l pKa8iCCA93Sy4HAZIR2vfKBoffPvoMFkcMBBQOWzRwB2/lGffYjQsVxtHeeJfJafPYgJ sRjQ== X-Received: by 10.66.100.226 with SMTP id fb2mr8097175pab.92.1422166372093; Sat, 24 Jan 2015 22:12:52 -0800 (PST) MIME-Version: 1.0 Received: by 10.70.120.70 with HTTP; Sat, 24 Jan 2015 22:12:11 -0800 (PST) In-Reply-To: References: From: Pavel Stehule Date: Sun, 25 Jan 2015 07:12:11 +0100 Message-ID: Subject: Re: Query performance To: Joe Van Dyk Cc: "pgsql-performance@postgresql.org" Content-Type: multipart/alternative; boundary=047d7bd908906b94bb050d73e911 X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org --047d7bd908906b94bb050d73e911 Content-Type: text/plain; charset=UTF-8 Hi this plan looks well Regards Pavel 2015-01-25 6:45 GMT+01:00 Joe Van Dyk : > Oops, didn't run vacuum analyze after deleting the events. Here is another > 'explain analyze': http://explain.depesz.com/s/AviN > > On Sat, Jan 24, 2015 at 9:43 PM, Joe Van Dyk wrote: > >> On Sat, Jan 24, 2015 at 9:41 PM, Joe Van Dyk wrote: >> >>> I have an events table that records page views and purchases (type = >>> 'viewed' or type='purchased'). I have a query that figures out "people who >>> bought/viewed this also bought/viewed that". >>> >>> It worked fine, taking about 0.1 seconds to complete, until a few hours >>> ago when it started taking hours to complete. Vacuum/analyze didn't help. >>> Turned out there was one session_id that had 400k rows in the system. >>> Deleting that made the query performant again. >>> >>> Is there anything I can do to make the query work better in cases like >>> that? Missing index, or better query? >>> >>> This is on 9.3.5. >>> >>> The below is reproduced at the following URL if it's not formatted >>> correctly in the email. >>> https://gist.githubusercontent.com/joevandyk/cb8f4afdb6c1b178c606/raw/9940bbe033ebd56d38caa46e33c1ddfd9df36eda/gistfile1.txt >>> >>> explain select >>> e1.product_id, >>> e2.site_id, >>> e2.product_id, >>> count(nullif(e2.type='viewed', false)) view_count, >>> count(nullif(e2.type='purchased', false)) purchase_count >>> from events e1 >>> join events e2 on e1.session_id = e2.session_id and e1.type = e2.type >>> where >>> e1.product_id = '82503' and >>> e1.product_id != e2.product_id >>> group by e1.product_id, e2.product_id, e2.site_id; >>> QUERY PLAN >>> ---------------------------------------------------------------------------------------------------------------------------- >>> GroupAggregate (cost=828395.67..945838.90 rows=22110 width=19) >>> -> Sort (cost=828395.67..840117.89 rows=4688885 width=19) >>> Sort Key: e1.product_id, e2.product_id, e2.site_id >>> -> Nested Loop (cost=11.85..20371.14 rows=4688885 width=19) >>> -> Bitmap Heap Scan on events e1 (cost=11.29..1404.31 rows=369 width=49) >>> Recheck Cond: (product_id = '82503'::citext) >>> -> Bitmap Index Scan on events_product_id_site_id_idx (cost=0.00..11.20 rows=369 width=0) >>> Index Cond: (product_id = '82503'::citext) >>> -> Index Scan using events_session_id_type_product_id_idx on events e2 (cost=0.56..51.28 rows=12 width=51) >>> Index Cond: ((session_id = e1.session_id) AND (type = e1.type)) >>> Filter: (e1.product_id <> product_id) >>> (11 rows) >>> >>> recommender_production=> \d events >>> Table "public.events" >>> Column | Type | Modifiers >>> -------------+--------------------------+----------------------------------------------------- >>> id | bigint | not null default nextval('events_id_seq'::regclass) >>> user_id | citext | >>> session_id | citext | not null >>> product_id | citext | not null >>> site_id | citext | not null >>> type | text | not null >>> happened_at | timestamp with time zone | not null >>> created_at | timestamp with time zone | not null >>> Indexes: >>> "events_pkey" PRIMARY KEY, btree (id) >>> "events_product_id_site_id_idx" btree (product_id, site_id) >>> "events_session_id_type_product_id_idx" btree (session_id, type, product_id) >>> Check constraints: >>> "events_session_id_check" CHECK (length(session_id::text) < 255) >>> "events_type_check" CHECK (type = ANY (ARRAY['purchased'::text, 'viewed'::text])) >>> "events_user_id_check" CHECK (length(user_id::text) < 255) >>> >>> >>> >>> >> After removing the session with 400k events, I was able to do an explain >> analyze, here is one of them: >> http://explain.depesz.com/s/PFNk >> > > --047d7bd908906b94bb050d73e911 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi

this plan looks well

Regards

Pavel

2015-01-25 6:45 GMT+01:00 Joe Van Dyk &l= t;joe@tanga.com><= /span>:
Oops, didn't= run vacuum analyze after deleting the events. Here is another 'explain= analyze':=C2=A0http://explain.depesz.com/s/AviN

On Sat, Jan 24, 2015 at 9:43 PM, Joe Van Dyk <joe@tanga.com> w= rote:
On Sat, Jan 24, 2015 at 9:41 = PM, Joe Van Dyk <joe@tanga.com> wrote:
I have an events table that records page views and purchas= es (type =3D 'viewed' or type=3D'purchased'). I have a quer= y that figures out "people who bought/viewed this also bought/viewed t= hat".

It worked fine, taking about 0.1 second= s to complete, until a few hours ago when it started taking hours to comple= te. Vacuum/analyze didn't help.=C2=A0 Turned out there was one session_= id that had 400k rows in the system. Deleting that made the query performan= t again.=C2=A0

Is there anything I can do to make = the query work better in cases like that? Missing index, or better query?

This is on 9.3.5.

The below is = reproduced at the following URL if it's not formatted correctly in the = email. https://gist.githubusercontent.com/joevandyk/cb8f4afdb6c1b178c6= 06/raw/9940bbe033ebd56d38caa46e33c1ddfd9df36eda/gistfile1.txt

<= /div>
explain  select
   e1.product_id,
   e2.site_id,
   e2.product_id,
   count(nullif(e2.type=3D'viewed', false)) view_count,
   count(nullif(e2.type=3D'purchased', false)) purchase_count
 from events e1
 join events e2 on e1.session_id =3D e2.session_id and e1.type =3D e2.type
 where
   e1.product_id =3D '82503' and
   e1.product_id !=3D e2.product_id
 group by e1.product_id, e2.product_id, e2.site_id;
                                                         QUERY PLAN
---------------------------------------------------------------------------=
-------------------------------------------------
 GroupAggregate  (cost=3D828395.67..945838.90 rows=3D22110 width=3D19)
   ->  Sort  (cost=3D828395.67..840117.89 rows=3D4688885 width=3D19)
         Sort Key: e1.product_id, e2.product_id, e2.site_id
         ->  Nested Loop  (cost=3D11.85..20371.14 rows=3D4688885 width=
=3D19)
               ->  Bitmap Heap Scan on events e1  (cost=3D11.29..1404.31=
 rows=3D369 width=3D49)
                     Recheck Cond: (product_id =3D '82503'::citext)
                     ->  Bitmap Index Scan on events_product_id_site_id_=
idx  (cost=3D0.00..11.20 rows=3D369 width=3D0)
                           Index Cond: (product_id =3D '82503'::cit=
ext)
               ->  Index Scan using events_session_id_type_product_id_id=
x on events e2  (cost=3D0.56..51.28 rows=3D12 width=3D51)
                     Index Cond: ((session_id =3D e1.session_id) AND (type =
=3D e1.type))
                     Filter: (e1.product_id <> product_id)
(11 rows)

recommender_production=3D> \d events
                                    Table "public.events"
   Column    |           Type           |                      Modifiers
-------------+--------------------------+----------------------------------=
-------------------
 id          | bigint                   | not null default nextval('eve=
nts_id_seq'::regclass)
 user_id     | citext                   |
 session_id  | citext                   | not null
 product_id  | citext                   | not null
 site_id     | citext                   | not null
 type        | text                     | not null
 happened_at | timestamp with time zone | not null
 created_at  | timestamp with time zone | not null
Indexes:
    "events_pkey" PRIMARY KEY, btree (id)
    "events_product_id_site_id_idx" btree (product_id, site_id)
    "events_session_id_type_product_id_idx" btree (session_id, ty=
pe, product_id)
Check constraints:
    "events_session_id_check" CHECK (length(session_id::text) <=
; 255)
    "events_type_check" CHECK (type =3D ANY (ARRAY['purchased=
'::text, 'viewed'::text]))
    "events_user_id_check" CHECK (length(user_id::text) < 255)=



After r= emoving the session with 400k events, I was able to do an explain analyze, = here is one of them:


--047d7bd908906b94bb050d73e911-- From joe@tanga.com Sun Jan 25 06:38:55 2015 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YFGqV-0003BF-0M for pgsql-performance@arkaria.postgresql.org; Sun, 25 Jan 2015 06:38:55 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YFGqT-0000XC-Ot for pgsql-performance@arkaria.postgresql.org; Sun, 25 Jan 2015 06:38:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YFGqS-0000X3-7B for pgsql-performance@postgresql.org; Sun, 25 Jan 2015 06:38:52 +0000 Received: from mail-qc0-x236.google.com ([2607:f8b0:400d:c01::236]) by magus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YFGqM-0000od-Q6 for pgsql-performance@postgresql.org; Sun, 25 Jan 2015 06:38:50 +0000 Received: by mail-qc0-f182.google.com with SMTP id l6so3296573qcy.13 for ; Sat, 24 Jan 2015 22:38:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=8LmV39FrV35dXzmqUO6hbO0yo2ThyV+OpEcrIe34JVI=; b=pjhztXJPhYeKlYmunZM1tJNllLySYrgPwNu8nKa2xoJwywxrMyLzojrqzVK5TJB/L0 fXEBgvEZmfhcqNDem2R/RmeaaZk91nIH2S8+tDoBs8w6euqZERFfOsV/T7F9b+hIDt7K 6XTTZD5CnRsZfnfkfeMUOAzzLdpNzrlfuYTi4GmuGab+KLHUsRTJHU8GjOcopRNPwS/G AZ8Fxgcps6B0qrAE1eK+gJ6KSMQBGY1zDX1w6UhYUEi1ROEjXNntGfUUIjMN87nWZ8T0 5FsQp1w+SyZGVs8nimbHHmscYuJgivhaKfwdkx2/EWCUvgaRfDYYyWVHApO5vnQM2uzM 42Uw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tanga.com; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=8LmV39FrV35dXzmqUO6hbO0yo2ThyV+OpEcrIe34JVI=; b=PByNZHNhw+OOSzjXqrqxL6IKTZFh9lSSlIBbOVzDAW7npeRQgyeGMm8/yhva1aApZZ VhxLnTMQVXGQAmMyeaSgd0EV4RPt7XMt8YZwXBvWDDAkEvOZDrISkLMjdXzXO9q8a78d dkk0mcKu61tWh67/FScXcgkBTgnEsHX9maX7I= X-Received: by 10.140.19.139 with SMTP id 11mr29767697qgh.14.1422167924634; Sat, 24 Jan 2015 22:38:44 -0800 (PST) MIME-Version: 1.0 Received: by 10.140.240.23 with HTTP; Sat, 24 Jan 2015 22:38:04 -0800 (PST) In-Reply-To: References: From: Joe Van Dyk Date: Sat, 24 Jan 2015 22:38:04 -0800 X-Google-Sender-Auth: aOHriFfMgx0v6pJtigq0Ky4XmKk Message-ID: Subject: Re: Query performance To: Pavel Stehule Cc: "pgsql-performance@postgresql.org" Content-Type: multipart/alternative; boundary=001a1134f03cf57c22050d744596 X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org --001a1134f03cf57c22050d744596 Content-Type: text/plain; charset=UTF-8 On Sat, Jan 24, 2015 at 10:12 PM, Pavel Stehule wrote: > Hi > > this plan looks well > > Regards > > Pavel > Here's one that's not quite as well: http://explain.depesz.com/s/SgT Joe > > 2015-01-25 6:45 GMT+01:00 Joe Van Dyk : > >> Oops, didn't run vacuum analyze after deleting the events. Here is >> another 'explain analyze': http://explain.depesz.com/s/AviN >> >> On Sat, Jan 24, 2015 at 9:43 PM, Joe Van Dyk wrote: >> >>> On Sat, Jan 24, 2015 at 9:41 PM, Joe Van Dyk wrote: >>> >>>> I have an events table that records page views and purchases (type = >>>> 'viewed' or type='purchased'). I have a query that figures out "people who >>>> bought/viewed this also bought/viewed that". >>>> >>>> It worked fine, taking about 0.1 seconds to complete, until a few hours >>>> ago when it started taking hours to complete. Vacuum/analyze didn't help. >>>> Turned out there was one session_id that had 400k rows in the system. >>>> Deleting that made the query performant again. >>>> >>>> Is there anything I can do to make the query work better in cases like >>>> that? Missing index, or better query? >>>> >>>> This is on 9.3.5. >>>> >>>> The below is reproduced at the following URL if it's not formatted >>>> correctly in the email. >>>> https://gist.githubusercontent.com/joevandyk/cb8f4afdb6c1b178c606/raw/9940bbe033ebd56d38caa46e33c1ddfd9df36eda/gistfile1.txt >>>> >>>> explain select >>>> e1.product_id, >>>> e2.site_id, >>>> e2.product_id, >>>> count(nullif(e2.type='viewed', false)) view_count, >>>> count(nullif(e2.type='purchased', false)) purchase_count >>>> from events e1 >>>> join events e2 on e1.session_id = e2.session_id and e1.type = e2.type >>>> where >>>> e1.product_id = '82503' and >>>> e1.product_id != e2.product_id >>>> group by e1.product_id, e2.product_id, e2.site_id; >>>> QUERY PLAN >>>> ---------------------------------------------------------------------------------------------------------------------------- >>>> GroupAggregate (cost=828395.67..945838.90 rows=22110 width=19) >>>> -> Sort (cost=828395.67..840117.89 rows=4688885 width=19) >>>> Sort Key: e1.product_id, e2.product_id, e2.site_id >>>> -> Nested Loop (cost=11.85..20371.14 rows=4688885 width=19) >>>> -> Bitmap Heap Scan on events e1 (cost=11.29..1404.31 rows=369 width=49) >>>> Recheck Cond: (product_id = '82503'::citext) >>>> -> Bitmap Index Scan on events_product_id_site_id_idx (cost=0.00..11.20 rows=369 width=0) >>>> Index Cond: (product_id = '82503'::citext) >>>> -> Index Scan using events_session_id_type_product_id_idx on events e2 (cost=0.56..51.28 rows=12 width=51) >>>> Index Cond: ((session_id = e1.session_id) AND (type = e1.type)) >>>> Filter: (e1.product_id <> product_id) >>>> (11 rows) >>>> >>>> recommender_production=> \d events >>>> Table "public.events" >>>> Column | Type | Modifiers >>>> -------------+--------------------------+----------------------------------------------------- >>>> id | bigint | not null default nextval('events_id_seq'::regclass) >>>> user_id | citext | >>>> session_id | citext | not null >>>> product_id | citext | not null >>>> site_id | citext | not null >>>> type | text | not null >>>> happened_at | timestamp with time zone | not null >>>> created_at | timestamp with time zone | not null >>>> Indexes: >>>> "events_pkey" PRIMARY KEY, btree (id) >>>> "events_product_id_site_id_idx" btree (product_id, site_id) >>>> "events_session_id_type_product_id_idx" btree (session_id, type, product_id) >>>> Check constraints: >>>> "events_session_id_check" CHECK (length(session_id::text) < 255) >>>> "events_type_check" CHECK (type = ANY (ARRAY['purchased'::text, 'viewed'::text])) >>>> "events_user_id_check" CHECK (length(user_id::text) < 255) >>>> >>>> >>>> >>>> >>> After removing the session with 400k events, I was able to do an explain >>> analyze, here is one of them: >>> http://explain.depesz.com/s/PFNk >>> >> >> > --001a1134f03cf57c22050d744596 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


On Sat, Jan 24, 2015 at 10:12 PM, Pavel Stehule <<= a href=3D"mailto:pavel.stehule@gmail.com" target=3D"_blank">pavel.stehule@g= mail.com> wrote:
=
Hi

this plan looks well

Regards

Pavel

Here's one that's not quite as well: http://explain.depesz.com/s/SgT<= /div>

Joe
=C2=A0

2015-01-25 6:45 GMT+01:00 Joe Van Dyk <joe@tanga.com>:
Oops, didn't run vacuum analyz= e after deleting the events. Here is another 'explain analyze':=C2= =A0http://ex= plain.depesz.com/s/AviN
<= br>
On Sat, Jan 24, 2015 at 9:43 PM, Joe Van Dyk = <jo= e@tanga.com> wrote:
On Sat, Jan 24,= 2015 at 9:41 PM, Joe Van Dyk <joe@tanga.com> wrote:
I have an events table that records page vie= ws and purchases (type =3D 'viewed' or type=3D'purchased').= I have a query that figures out "people who bought/viewed this also b= ought/viewed that".

It worked fine, taking ab= out 0.1 seconds to complete, until a few hours ago when it started taking h= ours to complete. Vacuum/analyze didn't help.=C2=A0 Turned out there wa= s one session_id that had 400k rows in the system. Deleting that made the q= uery performant again.=C2=A0

Is there anything I c= an do to make the query work better in cases like that? Missing index, or b= etter query?

This is on 9.3.5.

The below is reproduced at the following URL if it's not formatted cor= rectly in the email. https://gist.githubusercontent.com/joevandyk/cb8f= 4afdb6c1b178c606/raw/9940bbe033ebd56d38caa46e33c1ddfd9df36eda/gistfile1.txt=

explain  select
   e1.product_id,
   e2.site_id,
   e2.product_id,
   count(nullif(e2.type=3D'viewed', false)) view_count,
   count(nullif(e2.type=3D'purchased', false)) purchase_count
 from events e1
 join events e2 on e1.session_id =3D e2.session_id and e1.type =3D e2.type
 where
   e1.product_id =3D '82503' and
   e1.product_id !=3D e2.product_id
 group by e1.product_id, e2.product_id, e2.site_id;
                                                         QUERY PLAN
---------------------------------------------------------------------------=
-------------------------------------------------
 GroupAggregate  (cost=3D828395.67..945838.90 rows=3D22110 width=3D19)
   ->  Sort  (cost=3D828395.67..840117.89 rows=3D4688885 width=3D19)
         Sort Key: e1.product_id, e2.product_id, e2.site_id
         ->  Nested Loop  (cost=3D11.85..20371.14 rows=3D4688885 width=
=3D19)
               ->  Bitmap Heap Scan on events e1  (cost=3D11.29..1404.31=
 rows=3D369 width=3D49)
                     Recheck Cond: (product_id =3D '82503'::citext)
                     ->  Bitmap Index Scan on events_product_id_site_id_=
idx  (cost=3D0.00..11.20 rows=3D369 width=3D0)
                           Index Cond: (product_id =3D '82503'::cit=
ext)
               ->  Index Scan using events_session_id_type_product_id_id=
x on events e2  (cost=3D0.56..51.28 rows=3D12 width=3D51)
                     Index Cond: ((session_id =3D e1.session_id) AND (type =
=3D e1.type))
                     Filter: (e1.product_id <> product_id)
(11 rows)

recommender_production=3D> \d events
                                    Table "public.events"
   Column    |           Type           |                      Modifiers
-------------+--------------------------+----------------------------------=
-------------------
 id          | bigint                   | not null default nextval('eve=
nts_id_seq'::regclass)
 user_id     | citext                   |
 session_id  | citext                   | not null
 product_id  | citext                   | not null
 site_id     | citext                   | not null
 type        | text                     | not null
 happened_at | timestamp with time zone | not null
 created_at  | timestamp with time zone | not null
Indexes:
    "events_pkey" PRIMARY KEY, btree (id)
    "events_product_id_site_id_idx" btree (product_id, site_id)
    "events_session_id_type_product_id_idx" btree (session_id, ty=
pe, product_id)
Check constraints:
    "events_session_id_check" CHECK (length(session_id::text) <=
; 255)
    "events_type_check" CHECK (type =3D ANY (ARRAY['purchased=
'::text, 'viewed'::text]))
    "events_user_id_check" CHECK (length(user_id::text) < 255)=



After r= emoving the session with 400k events, I was able to do an explain analyze, = here is one of them:



--001a1134f03cf57c22050d744596-- From pavel.stehule@gmail.com Sun Jan 25 07:14:57 2015 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YFHPM-0004Sx-SC for pgsql-performance@arkaria.postgresql.org; Sun, 25 Jan 2015 07:14:57 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YFHPL-0003BT-P8 for pgsql-performance@arkaria.postgresql.org; Sun, 25 Jan 2015 07:14:55 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YFHPK-0003BM-9S for pgsql-performance@postgresql.org; Sun, 25 Jan 2015 07:14:54 +0000 Received: from mail-pa0-x233.google.com ([2607:f8b0:400e:c03::233]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YFHPF-0000lX-Ps for pgsql-performance@postgresql.org; Sun, 25 Jan 2015 07:14:52 +0000 Received: by mail-pa0-f51.google.com with SMTP id fb1so5660036pad.10 for ; Sat, 24 Jan 2015 23:14:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=C0bFVYReJxpJsynAgO5v3sB01m4tmb+AO64z4g4ioec=; b=pLJ6rYUhvCBH9WZGXxta67DJmNoPLyW5H85SNromT3dEWK5KF8Ue4aJapDqk1htIJZ GMoc50WlgVwrImisW1DK8TJEIfMXqlasCFK97CPcpxhIYXM7ljH/1P4qc+0bBSdUFP8p IpLEmJ7/k+gCy4X0PKWCOtK9w6Z1ePlJyEBLpE+rkq6njSdfGJZ0adv3XWVIO5d5bHqD RgTtoolQdF0NPSNBeZ6dWEs1hXkW5vEkqSQUqhtN6FKGHEFdb3YMjKTI/cWz+Y1PJYv2 3wmqvFiMabuxMZHaKbStAy9vuKPpO3xaG9z8GGbt+WNGugILP1MoFUkWHzR9LgwoexvD oKxQ== X-Received: by 10.68.136.137 with SMTP id qa9mr24616967pbb.127.1422170088430; Sat, 24 Jan 2015 23:14:48 -0800 (PST) MIME-Version: 1.0 Received: by 10.70.120.70 with HTTP; Sat, 24 Jan 2015 23:14:08 -0800 (PST) In-Reply-To: References: From: Pavel Stehule Date: Sun, 25 Jan 2015 08:14:08 +0100 Message-ID: Subject: Re: Query performance To: Joe Van Dyk Cc: "pgsql-performance@postgresql.org" Content-Type: multipart/alternative; boundary=047d7b10cff7ee64d4050d74c6e4 X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org --047d7b10cff7ee64d4050d74c6e4 Content-Type: text/plain; charset=UTF-8 2015-01-25 7:38 GMT+01:00 Joe Van Dyk : > > > On Sat, Jan 24, 2015 at 10:12 PM, Pavel Stehule > wrote: > >> Hi >> >> this plan looks well >> >> Regards >> >> Pavel >> > > Here's one that's not quite as well: http://explain.depesz.com/s/SgT > I see a possible issue (product_id <> '81716'::citext) .. this operation is CPU expensive and maybe nonsense product_id should be integer -- and if it isn't - it should not be on 4M rows extremly fast - mainly on citext try to force a opposite cast - you will safe a case insensitive text comparation product_id::int <> 81716 Regards Pavel > > Joe > > >> >> 2015-01-25 6:45 GMT+01:00 Joe Van Dyk : >> >>> Oops, didn't run vacuum analyze after deleting the events. Here is >>> another 'explain analyze': http://explain.depesz.com/s/AviN >>> >>> On Sat, Jan 24, 2015 at 9:43 PM, Joe Van Dyk wrote: >>> >>>> On Sat, Jan 24, 2015 at 9:41 PM, Joe Van Dyk wrote: >>>> >>>>> I have an events table that records page views and purchases (type = >>>>> 'viewed' or type='purchased'). I have a query that figures out "people who >>>>> bought/viewed this also bought/viewed that". >>>>> >>>>> It worked fine, taking about 0.1 seconds to complete, until a few >>>>> hours ago when it started taking hours to complete. Vacuum/analyze didn't >>>>> help. Turned out there was one session_id that had 400k rows in the >>>>> system. Deleting that made the query performant again. >>>>> >>>>> Is there anything I can do to make the query work better in cases like >>>>> that? Missing index, or better query? >>>>> >>>>> This is on 9.3.5. >>>>> >>>>> The below is reproduced at the following URL if it's not formatted >>>>> correctly in the email. >>>>> https://gist.githubusercontent.com/joevandyk/cb8f4afdb6c1b178c606/raw/9940bbe033ebd56d38caa46e33c1ddfd9df36eda/gistfile1.txt >>>>> >>>>> explain select >>>>> e1.product_id, >>>>> e2.site_id, >>>>> e2.product_id, >>>>> count(nullif(e2.type='viewed', false)) view_count, >>>>> count(nullif(e2.type='purchased', false)) purchase_count >>>>> from events e1 >>>>> join events e2 on e1.session_id = e2.session_id and e1.type = e2.type >>>>> where >>>>> e1.product_id = '82503' and >>>>> e1.product_id != e2.product_id >>>>> group by e1.product_id, e2.product_id, e2.site_id; >>>>> QUERY PLAN >>>>> ---------------------------------------------------------------------------------------------------------------------------- >>>>> GroupAggregate (cost=828395.67..945838.90 rows=22110 width=19) >>>>> -> Sort (cost=828395.67..840117.89 rows=4688885 width=19) >>>>> Sort Key: e1.product_id, e2.product_id, e2.site_id >>>>> -> Nested Loop (cost=11.85..20371.14 rows=4688885 width=19) >>>>> -> Bitmap Heap Scan on events e1 (cost=11.29..1404.31 rows=369 width=49) >>>>> Recheck Cond: (product_id = '82503'::citext) >>>>> -> Bitmap Index Scan on events_product_id_site_id_idx (cost=0.00..11.20 rows=369 width=0) >>>>> Index Cond: (product_id = '82503'::citext) >>>>> -> Index Scan using events_session_id_type_product_id_idx on events e2 (cost=0.56..51.28 rows=12 width=51) >>>>> Index Cond: ((session_id = e1.session_id) AND (type = e1.type)) >>>>> Filter: (e1.product_id <> product_id) >>>>> (11 rows) >>>>> >>>>> recommender_production=> \d events >>>>> Table "public.events" >>>>> Column | Type | Modifiers >>>>> -------------+--------------------------+----------------------------------------------------- >>>>> id | bigint | not null default nextval('events_id_seq'::regclass) >>>>> user_id | citext | >>>>> session_id | citext | not null >>>>> product_id | citext | not null >>>>> site_id | citext | not null >>>>> type | text | not null >>>>> happened_at | timestamp with time zone | not null >>>>> created_at | timestamp with time zone | not null >>>>> Indexes: >>>>> "events_pkey" PRIMARY KEY, btree (id) >>>>> "events_product_id_site_id_idx" btree (product_id, site_id) >>>>> "events_session_id_type_product_id_idx" btree (session_id, type, product_id) >>>>> Check constraints: >>>>> "events_session_id_check" CHECK (length(session_id::text) < 255) >>>>> "events_type_check" CHECK (type = ANY (ARRAY['purchased'::text, 'viewed'::text])) >>>>> "events_user_id_check" CHECK (length(user_id::text) < 255) >>>>> >>>>> >>>>> >>>>> >>>> After removing the session with 400k events, I was able to do an >>>> explain analyze, here is one of them: >>>> http://explain.depesz.com/s/PFNk >>>> >>> >>> >> > --047d7b10cff7ee64d4050d74c6e4 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


2015-01-25 7:38 GMT+01:00 Joe Van Dyk <joe@tanga.com>:
<= br>
I see a possible issue

(product_id <> '8171= 6'::citext) .. this operation is CPU expensive and maybe nonsense
<= br>
product_id should be integer -- and if it isn't - it shou= ld not be on 4M rows extremly fast - mainly on citext

tr= y to force a opposite cast - you will safe a case insensitive text comparat= ion

product_id::int <> 81716

Rega= rds

Pavel


=C2=A0

Joe
=C2=A0

2015-01-25 6:45 GMT+01= :00 Joe Van Dyk <joe@tanga.com>:
Oops, didn't run vacuum analyze = after deleting the events. Here is another 'explain analyze':=C2=A0= http://expla= in.depesz.com/s/AviN

=
On Sat, Jan 24, 2015 at 9:43 PM, Joe Van Dyk <joe@t= anga.com> wrote:
On Sat, Jan 24, 2015 at 9:41 PM, Joe Van Dyk <joe@tanga.com> wrote:
<= div dir=3D"ltr">
I have an events table that records page views and pur= chases (type =3D 'viewed' or type=3D'purchased'). I have a = query that figures out "people who bought/viewed this also bought/view= ed that".

It worked fine, taking about 0.1 se= conds to complete, until a few hours ago when it started taking hours to co= mplete. Vacuum/analyze didn't help.=C2=A0 Turned out there was one sess= ion_id that had 400k rows in the system. Deleting that made the query perfo= rmant again.=C2=A0

Is there anything I can do to m= ake the query work better in cases like that? Missing index, or better quer= y?

This is on 9.3.5.

The below= is reproduced at the following URL if it's not formatted correctly in = the email.
https://gist.githubusercontent.com/joevandyk/cb8f4afdb6c1b1= 78c606/raw/9940bbe033ebd56d38caa46e33c1ddfd9df36eda/gistfile1.txt
<= br>
explain  select
   e1.product_id,
   e2.site_id,
   e2.product_id,
   count(nullif(e2.type=3D'viewed', false)) view_count,
   count(nullif(e2.type=3D'purchased', false)) purchase_count
 from events e1
 join events e2 on e1.session_id =3D e2.session_id and e1.type =3D e2.type
 where
   e1.product_id =3D '82503' and
   e1.product_id !=3D e2.product_id
 group by e1.product_id, e2.product_id, e2.site_id;
                                                         QUERY PLAN
---------------------------------------------------------------------------=
-------------------------------------------------
 GroupAggregate  (cost=3D828395.67..945838.90 rows=3D22110 width=3D19)
   ->  Sort  (cost=3D828395.67..840117.89 rows=3D4688885 width=3D19)
         Sort Key: e1.product_id, e2.product_id, e2.site_id
         ->  Nested Loop  (cost=3D11.85..20371.14 rows=3D4688885 width=
=3D19)
               ->  Bitmap Heap Scan on events e1  (cost=3D11.29..1404.31=
 rows=3D369 width=3D49)
                     Recheck Cond: (product_id =3D '82503'::citext)
                     ->  Bitmap Index Scan on events_product_id_site_id_=
idx  (cost=3D0.00..11.20 rows=3D369 width=3D0)
                           Index Cond: (product_id =3D '82503'::cit=
ext)
               ->  Index Scan using events_session_id_type_product_id_id=
x on events e2  (cost=3D0.56..51.28 rows=3D12 width=3D51)
                     Index Cond: ((session_id =3D e1.session_id) AND (type =
=3D e1.type))
                     Filter: (e1.product_id <> product_id)
(11 rows)

recommender_production=3D> \d events
                                    Table "public.events"
   Column    |           Type           |                      Modifiers
-------------+--------------------------+----------------------------------=
-------------------
 id          | bigint                   | not null default nextval('eve=
nts_id_seq'::regclass)
 user_id     | citext                   |
 session_id  | citext                   | not null
 product_id  | citext                   | not null
 site_id     | citext                   | not null
 type        | text                     | not null
 happened_at | timestamp with time zone | not null
 created_at  | timestamp with time zone | not null
Indexes:
    "events_pkey" PRIMARY KEY, btree (id)
    "events_product_id_site_id_idx" btree (product_id, site_id)
    "events_session_id_type_product_id_idx" btree (session_id, ty=
pe, product_id)
Check constraints:
    "events_session_id_check" CHECK (length(session_id::text) <=
; 255)
    "events_type_check" CHECK (type =3D ANY (ARRAY['purchased=
'::text, 'viewed'::text]))
    "events_user_id_check" CHECK (length(user_id::text) < 255)=



After r= emoving the session with 400k events, I was able to do an explain analyze, = here is one of them:




--047d7b10cff7ee64d4050d74c6e4-- From joe@tanga.com Sun Jan 25 07:21:51 2015 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YFHW3-0004mH-88 for pgsql-performance@arkaria.postgresql.org; Sun, 25 Jan 2015 07:21:51 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YFHW2-0005Af-OM for pgsql-performance@arkaria.postgresql.org; Sun, 25 Jan 2015 07:21:50 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YFHW1-0005AY-8y for pgsql-performance@postgresql.org; Sun, 25 Jan 2015 07:21:49 +0000 Received: from mail-qg0-x22d.google.com ([2607:f8b0:400d:c04::22d]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YFHVt-0000wD-0x for pgsql-performance@postgresql.org; Sun, 25 Jan 2015 07:21:47 +0000 Received: by mail-qg0-f45.google.com with SMTP id q107so3325133qgd.4 for ; Sat, 24 Jan 2015 23:21:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=IAWlpWfjZCaxgdS05wwMCqMtuXtgwaL60Wm+ygd5/eM=; b=OGSB5eQeoEcqO7Dstc0qGtchtwioLttnKHtTtC9d7ktRqEMAnpGZu4TUzAgdqjnnza dIJaL3K6Z9zS7kuEeW+NuF0GhQKc7Fi4kEoei+5WOwPKcnbIBYTzk8nvM1Zt3VmHBjBp h2fAu5Uw+uRdxyWuLpkqjduLCYS0gMENeOdbCaAMmmtwuacbWqUj6h/8a3AEmwXTn7eH xXX7OPS7En5oVH7leTTIDNY7AjiitWdcfvw/BKzokHE1zjj/gzHyOg4G6MFMEcJ+rqvg FGKmOs0MEIV0L4FKeMTGozGlVxN8Nv1ZZqmZ/kltInuY69QEk3eUYjME4rn15gf1OuH3 GtdQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tanga.com; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=IAWlpWfjZCaxgdS05wwMCqMtuXtgwaL60Wm+ygd5/eM=; b=lMlHIIJAbPuTXssiCpINFMAl7Lcc+CKnLphoBf8u0ydXWqh4tf114OgP+rDfWHj8Nv gxGexYtFrygygjsgsrrU9G1mdX2plWymvJZm/0N6Kt+0keyhYxOie9UcX+cArVGapZR5 uWb+cSV0NgLpnCY7nJ4poRm5HrZGNX4zBQkrg= X-Received: by 10.224.112.9 with SMTP id u9mr24611374qap.18.1422170499813; Sat, 24 Jan 2015 23:21:39 -0800 (PST) MIME-Version: 1.0 Received: by 10.140.240.23 with HTTP; Sat, 24 Jan 2015 23:20:59 -0800 (PST) In-Reply-To: References: From: Joe Van Dyk Date: Sat, 24 Jan 2015 23:20:59 -0800 X-Google-Sender-Auth: JOJUqfF6nQw9UF6mGxmqSeBPdbs Message-ID: Subject: Re: Query performance To: Pavel Stehule Cc: "pgsql-performance@postgresql.org" Content-Type: multipart/alternative; boundary=001a11c2d62e73983c050d74df38 X-Pg-Spam-Score: -2.5 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org --001a11c2d62e73983c050d74df38 Content-Type: text/plain; charset=UTF-8 On Sat, Jan 24, 2015 at 11:14 PM, Pavel Stehule wrote: > > > 2015-01-25 7:38 GMT+01:00 Joe Van Dyk : > >> >> >> On Sat, Jan 24, 2015 at 10:12 PM, Pavel Stehule >> wrote: >> >>> Hi >>> >>> this plan looks well >>> >>> Regards >>> >>> Pavel >>> >> >> Here's one that's not quite as well: http://explain.depesz.com/s/SgT >> > > I see a possible issue > > (product_id <> '81716'::citext) .. this operation is CPU expensive and > maybe nonsense > > product_id should be integer -- and if it isn't - it should not be on 4M > rows extremly fast - mainly on citext > > try to force a opposite cast - you will safe a case insensitive text > comparation > > product_id::int <> 81716 > It might not always be an integer, just happens to be so here. Should I try text instead? I don't have to have the case-insensitive matching. Joe > > Regards > > Pavel > > > > >> >> Joe >> >> >>> >>> 2015-01-25 6:45 GMT+01:00 Joe Van Dyk : >>> >>>> Oops, didn't run vacuum analyze after deleting the events. Here is >>>> another 'explain analyze': http://explain.depesz.com/s/AviN >>>> >>>> On Sat, Jan 24, 2015 at 9:43 PM, Joe Van Dyk wrote: >>>> >>>>> On Sat, Jan 24, 2015 at 9:41 PM, Joe Van Dyk wrote: >>>>> >>>>>> I have an events table that records page views and purchases (type = >>>>>> 'viewed' or type='purchased'). I have a query that figures out "people who >>>>>> bought/viewed this also bought/viewed that". >>>>>> >>>>>> It worked fine, taking about 0.1 seconds to complete, until a few >>>>>> hours ago when it started taking hours to complete. Vacuum/analyze didn't >>>>>> help. Turned out there was one session_id that had 400k rows in the >>>>>> system. Deleting that made the query performant again. >>>>>> >>>>>> Is there anything I can do to make the query work better in cases >>>>>> like that? Missing index, or better query? >>>>>> >>>>>> This is on 9.3.5. >>>>>> >>>>>> The below is reproduced at the following URL if it's not formatted >>>>>> correctly in the email. >>>>>> https://gist.githubusercontent.com/joevandyk/cb8f4afdb6c1b178c606/raw/9940bbe033ebd56d38caa46e33c1ddfd9df36eda/gistfile1.txt >>>>>> >>>>>> explain select >>>>>> e1.product_id, >>>>>> e2.site_id, >>>>>> e2.product_id, >>>>>> count(nullif(e2.type='viewed', false)) view_count, >>>>>> count(nullif(e2.type='purchased', false)) purchase_count >>>>>> from events e1 >>>>>> join events e2 on e1.session_id = e2.session_id and e1.type = e2.type >>>>>> where >>>>>> e1.product_id = '82503' and >>>>>> e1.product_id != e2.product_id >>>>>> group by e1.product_id, e2.product_id, e2.site_id; >>>>>> QUERY PLAN >>>>>> ---------------------------------------------------------------------------------------------------------------------------- >>>>>> GroupAggregate (cost=828395.67..945838.90 rows=22110 width=19) >>>>>> -> Sort (cost=828395.67..840117.89 rows=4688885 width=19) >>>>>> Sort Key: e1.product_id, e2.product_id, e2.site_id >>>>>> -> Nested Loop (cost=11.85..20371.14 rows=4688885 width=19) >>>>>> -> Bitmap Heap Scan on events e1 (cost=11.29..1404.31 rows=369 width=49) >>>>>> Recheck Cond: (product_id = '82503'::citext) >>>>>> -> Bitmap Index Scan on events_product_id_site_id_idx (cost=0.00..11.20 rows=369 width=0) >>>>>> Index Cond: (product_id = '82503'::citext) >>>>>> -> Index Scan using events_session_id_type_product_id_idx on events e2 (cost=0.56..51.28 rows=12 width=51) >>>>>> Index Cond: ((session_id = e1.session_id) AND (type = e1.type)) >>>>>> Filter: (e1.product_id <> product_id) >>>>>> (11 rows) >>>>>> >>>>>> recommender_production=> \d events >>>>>> Table "public.events" >>>>>> Column | Type | Modifiers >>>>>> -------------+--------------------------+----------------------------------------------------- >>>>>> id | bigint | not null default nextval('events_id_seq'::regclass) >>>>>> user_id | citext | >>>>>> session_id | citext | not null >>>>>> product_id | citext | not null >>>>>> site_id | citext | not null >>>>>> type | text | not null >>>>>> happened_at | timestamp with time zone | not null >>>>>> created_at | timestamp with time zone | not null >>>>>> Indexes: >>>>>> "events_pkey" PRIMARY KEY, btree (id) >>>>>> "events_product_id_site_id_idx" btree (product_id, site_id) >>>>>> "events_session_id_type_product_id_idx" btree (session_id, type, product_id) >>>>>> Check constraints: >>>>>> "events_session_id_check" CHECK (length(session_id::text) < 255) >>>>>> "events_type_check" CHECK (type = ANY (ARRAY['purchased'::text, 'viewed'::text])) >>>>>> "events_user_id_check" CHECK (length(user_id::text) < 255) >>>>>> >>>>>> >>>>>> >>>>>> >>>>> After removing the session with 400k events, I was able to do an >>>>> explain analyze, here is one of them: >>>>> http://explain.depesz.com/s/PFNk >>>>> >>>> >>>> >>> >> > --001a11c2d62e73983c050d74df38 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On S= at, Jan 24, 2015 at 11:14 PM, Pavel Stehule <pavel.stehule@gmail.c= om> wrote:


2015-01-25 7:38 GMT+01:00 Joe Van Dyk <joe@tanga.com>:


On Sat, Jan 2= 4, 2015 at 10:12 PM, Pavel Stehule <pavel.stehule@gmail.com><= /span> wrote:
Hi

this plan looks well

Regard= s

Pavel

Here's one that's not quite as wel= l: http://exp= lain.depesz.com/s/SgT

I see a possible issue

(product_id <> '8171= 6'::citext) .. this operation is CPU expensive and maybe nonsense
<= br>
product_id should be integer -- and if it isn't - it shou= ld not be on 4M rows extremly fast - mainly on citext

tr= y to force a opposite cast - you will safe a case insensitive text comparat= ion

product_id::int <> 81716
<= /div>

It might not always be an integer, ju= st happens to be so here. Should I try text instead? I don't have to ha= ve the case-insensitive matching.

Joe
= =C2=A0

Regards

Pavel


=C2=A0

<= div>Joe
=C2=A0

2015-01-25 6:45 GMT+01:00 Joe Van Dyk <<= a href=3D"mailto:joe@tanga.com" target=3D"_blank">joe@tanga.com>:
= Oops, didn't run vacuum analyze after deleting the events. Here is anot= her 'explain analyze':=C2=A0http://explain.depesz.com/s/AviN
=

On Sat, Jan = 24, 2015 at 9:43 PM, Joe Van Dyk <joe@tanga.com> wrote:
On Sat, Jan 24, 2015 at = 9:41 PM, Joe Van Dyk <joe@tanga.com> wrote:
I have an events tab= le that records page views and purchases (type =3D 'viewed' or type= =3D'purchased'). I have a query that figures out "people who b= ought/viewed this also bought/viewed that".

I= t worked fine, taking about 0.1 seconds to complete, until a few hours ago = when it started taking hours to complete. Vacuum/analyze didn't help.= =C2=A0 Turned out there was one session_id that had 400k rows in the system= . Deleting that made the query performant again.=C2=A0

=
Is there anything I can do to make the query work better in cases like= that? Missing index, or better query?

This is on = 9.3.5.

The below is reproduced at the following URL if = it's not formatted correctly in the email. https://gist.githubuser= content.com/joevandyk/cb8f4afdb6c1b178c606/raw/9940bbe033ebd56d38caa46e33c1= ddfd9df36eda/gistfile1.txt

explain  =
select
   e1.product_id,
   e2.site_id,
   e2.product_id,
   count(nullif(e2.type=3D'viewed', false)) view_count,
   count(nullif(e2.type=3D'purchased', false)) purchase_count
 from events e1
 join events e2 on e1.session_id =3D e2.session_id and e1.type =3D e2.type
 where
   e1.product_id =3D '82503' and
   e1.product_id !=3D e2.product_id
 group by e1.product_id, e2.product_id, e2.site_id;
                                                         QUERY PLAN
---------------------------------------------------------------------------=
-------------------------------------------------
 GroupAggregate  (cost=3D828395.67..945838.90 rows=3D22110 width=3D19)
   ->  Sort  (cost=3D828395.67..840117.89 rows=3D4688885 width=3D19)
         Sort Key: e1.product_id, e2.product_id, e2.site_id
         ->  Nested Loop  (cost=3D11.85..20371.14 rows=3D4688885 width=
=3D19)
               ->  Bitmap Heap Scan on events e1  (cost=3D11.29..1404.31=
 rows=3D369 width=3D49)
                     Recheck Cond: (product_id =3D '82503'::citext)
                     ->  Bitmap Index Scan on events_product_id_site_id_=
idx  (cost=3D0.00..11.20 rows=3D369 width=3D0)
                           Index Cond: (product_id =3D '82503'::cit=
ext)
               ->  Index Scan using events_session_id_type_product_id_id=
x on events e2  (cost=3D0.56..51.28 rows=3D12 width=3D51)
                     Index Cond: ((session_id =3D e1.session_id) AND (type =
=3D e1.type))
                     Filter: (e1.product_id <> product_id)
(11 rows)

recommender_production=3D> \d events
                                    Table "public.events"
   Column    |           Type           |                      Modifiers
-------------+--------------------------+----------------------------------=
-------------------
 id          | bigint                   | not null default nextval('eve=
nts_id_seq'::regclass)
 user_id     | citext                   |
 session_id  | citext                   | not null
 product_id  | citext                   | not null
 site_id     | citext                   | not null
 type        | text                     | not null
 happened_at | timestamp with time zone | not null
 created_at  | timestamp with time zone | not null
Indexes:
    "events_pkey" PRIMARY KEY, btree (id)
    "events_product_id_site_id_idx" btree (product_id, site_id)
    "events_session_id_type_product_id_idx" btree (session_id, ty=
pe, product_id)
Check constraints:
    "events_session_id_check" CHECK (length(session_id::text) <=
; 255)
    "events_type_check" CHECK (type =3D ANY (ARRAY['purchased=
'::text, 'viewed'::text]))
    "events_user_id_check" CHECK (length(user_id::text) < 255)=



After r= emoving the session with 400k events, I was able to do an explain analyze, = here is one of them:





--001a11c2d62e73983c050d74df38-- From pavel.stehule@gmail.com Sun Jan 25 08:04:21 2015 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YFIBB-0006AI-HQ for pgsql-performance@arkaria.postgresql.org; Sun, 25 Jan 2015 08:04:21 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YFIBA-0007yE-Ba for pgsql-performance@arkaria.postgresql.org; Sun, 25 Jan 2015 08:04:20 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YFIB8-0007y7-Ql for pgsql-performance@postgresql.org; Sun, 25 Jan 2015 08:04:19 +0000 Received: from mail-pa0-x22a.google.com ([2607:f8b0:400e:c03::22a]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YFIB0-0001fC-CD for pgsql-performance@postgresql.org; Sun, 25 Jan 2015 08:04:16 +0000 Received: by mail-pa0-f42.google.com with SMTP id bj1so5833019pad.1 for ; Sun, 25 Jan 2015 00:04:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=6/7LWH1FAtsx26J8CSS8QwhKeNOd1E1tTfrX98q1YXo=; b=V9PNz9D2iIQ+3okndad4RlmDLk/DPw7f2y8K/DZHNrZvw8pk1CFzTRoV5G/mRegEX0 GGXRBLFL5LGDAJTD1HGQu7tNqMRGV71gHToMNnic41ky14f19jYeOEB/hOeDQ6nGWqSO uJ8XGeZ0FOuvBPzxmowYnD5wfqMWkRccKVpWDoPcn+v6v3euAS/ZVymNEwwq+wUrfCCH cC7QLn5O3kEzILeTmHbQYC9OB+7vlnvF9rf/LkC9NyGSNs5/wfIZ99tKmDFOsVuvYgmm qnj4w14imhXpLGGSS0u30rOPcK9UmWTuK1nljRHrM0T9wQnztsOrOI5vtw3ge28ZMrD2 tfpg== X-Received: by 10.68.242.163 with SMTP id wr3mr22924281pbc.159.1422173048995; Sun, 25 Jan 2015 00:04:08 -0800 (PST) MIME-Version: 1.0 Received: by 10.70.120.70 with HTTP; Sun, 25 Jan 2015 00:03:27 -0800 (PST) In-Reply-To: References: From: Pavel Stehule Date: Sun, 25 Jan 2015 09:03:27 +0100 Message-ID: Subject: Re: Query performance To: Joe Van Dyk Cc: "pgsql-performance@postgresql.org" Content-Type: multipart/alternative; boundary=047d7b339d416504e6050d757758 X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org --047d7b339d416504e6050d757758 Content-Type: text/plain; charset=UTF-8 2015-01-25 8:20 GMT+01:00 Joe Van Dyk : > On Sat, Jan 24, 2015 at 11:14 PM, Pavel Stehule > wrote: > >> >> >> 2015-01-25 7:38 GMT+01:00 Joe Van Dyk : >> >>> >>> >>> On Sat, Jan 24, 2015 at 10:12 PM, Pavel Stehule >> > wrote: >>> >>>> Hi >>>> >>>> this plan looks well >>>> >>>> Regards >>>> >>>> Pavel >>>> >>> >>> Here's one that's not quite as well: http://explain.depesz.com/s/SgT >>> >> >> I see a possible issue >> >> (product_id <> '81716'::citext) .. this operation is CPU expensive and >> maybe nonsense >> >> product_id should be integer -- and if it isn't - it should not be on 4M >> rows extremly fast - mainly on citext >> >> try to force a opposite cast - you will safe a case insensitive text >> comparation >> >> product_id::int <> 81716 >> > > It might not always be an integer, just happens to be so here. Should I > try text instead? I don't have to have the case-insensitive matching. > text can be better this design is unhappy, but you cannot to change ot probably > > Joe > > >> >> Regards >> >> Pavel >> >> >> >> >>> >>> Joe >>> >>> >>>> >>>> 2015-01-25 6:45 GMT+01:00 Joe Van Dyk : >>>> >>>>> Oops, didn't run vacuum analyze after deleting the events. Here is >>>>> another 'explain analyze': http://explain.depesz.com/s/AviN >>>>> >>>>> On Sat, Jan 24, 2015 at 9:43 PM, Joe Van Dyk wrote: >>>>> >>>>>> On Sat, Jan 24, 2015 at 9:41 PM, Joe Van Dyk wrote: >>>>>> >>>>>>> I have an events table that records page views and purchases (type = >>>>>>> 'viewed' or type='purchased'). I have a query that figures out "people who >>>>>>> bought/viewed this also bought/viewed that". >>>>>>> >>>>>>> It worked fine, taking about 0.1 seconds to complete, until a few >>>>>>> hours ago when it started taking hours to complete. Vacuum/analyze didn't >>>>>>> help. Turned out there was one session_id that had 400k rows in the >>>>>>> system. Deleting that made the query performant again. >>>>>>> >>>>>>> Is there anything I can do to make the query work better in cases >>>>>>> like that? Missing index, or better query? >>>>>>> >>>>>>> This is on 9.3.5. >>>>>>> >>>>>>> The below is reproduced at the following URL if it's not formatted >>>>>>> correctly in the email. >>>>>>> https://gist.githubusercontent.com/joevandyk/cb8f4afdb6c1b178c606/raw/9940bbe033ebd56d38caa46e33c1ddfd9df36eda/gistfile1.txt >>>>>>> >>>>>>> explain select >>>>>>> e1.product_id, >>>>>>> e2.site_id, >>>>>>> e2.product_id, >>>>>>> count(nullif(e2.type='viewed', false)) view_count, >>>>>>> count(nullif(e2.type='purchased', false)) purchase_count >>>>>>> from events e1 >>>>>>> join events e2 on e1.session_id = e2.session_id and e1.type = e2.type >>>>>>> where >>>>>>> e1.product_id = '82503' and >>>>>>> e1.product_id != e2.product_id >>>>>>> group by e1.product_id, e2.product_id, e2.site_id; >>>>>>> QUERY PLAN >>>>>>> ---------------------------------------------------------------------------------------------------------------------------- >>>>>>> GroupAggregate (cost=828395.67..945838.90 rows=22110 width=19) >>>>>>> -> Sort (cost=828395.67..840117.89 rows=4688885 width=19) >>>>>>> Sort Key: e1.product_id, e2.product_id, e2.site_id >>>>>>> -> Nested Loop (cost=11.85..20371.14 rows=4688885 width=19) >>>>>>> -> Bitmap Heap Scan on events e1 (cost=11.29..1404.31 rows=369 width=49) >>>>>>> Recheck Cond: (product_id = '82503'::citext) >>>>>>> -> Bitmap Index Scan on events_product_id_site_id_idx (cost=0.00..11.20 rows=369 width=0) >>>>>>> Index Cond: (product_id = '82503'::citext) >>>>>>> -> Index Scan using events_session_id_type_product_id_idx on events e2 (cost=0.56..51.28 rows=12 width=51) >>>>>>> Index Cond: ((session_id = e1.session_id) AND (type = e1.type)) >>>>>>> Filter: (e1.product_id <> product_id) >>>>>>> (11 rows) >>>>>>> >>>>>>> recommender_production=> \d events >>>>>>> Table "public.events" >>>>>>> Column | Type | Modifiers >>>>>>> -------------+--------------------------+----------------------------------------------------- >>>>>>> id | bigint | not null default nextval('events_id_seq'::regclass) >>>>>>> user_id | citext | >>>>>>> session_id | citext | not null >>>>>>> product_id | citext | not null >>>>>>> site_id | citext | not null >>>>>>> type | text | not null >>>>>>> happened_at | timestamp with time zone | not null >>>>>>> created_at | timestamp with time zone | not null >>>>>>> Indexes: >>>>>>> "events_pkey" PRIMARY KEY, btree (id) >>>>>>> "events_product_id_site_id_idx" btree (product_id, site_id) >>>>>>> "events_session_id_type_product_id_idx" btree (session_id, type, product_id) >>>>>>> Check constraints: >>>>>>> "events_session_id_check" CHECK (length(session_id::text) < 255) >>>>>>> "events_type_check" CHECK (type = ANY (ARRAY['purchased'::text, 'viewed'::text])) >>>>>>> "events_user_id_check" CHECK (length(user_id::text) < 255) >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>> After removing the session with 400k events, I was able to do an >>>>>> explain analyze, here is one of them: >>>>>> http://explain.depesz.com/s/PFNk >>>>>> >>>>> >>>>> >>>> >>> >> > --047d7b339d416504e6050d757758 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


2015-01-25 8:20 GMT+01:00 Joe Van Dyk <joe@tanga.com>:
On Sat, Jan 24, 2015 at 11:14 PM,= Pavel Stehule <pavel.stehule@gmail.com> wrote:


2015-01-25 7:38 GMT+01:00 Joe Van Dyk= <j= oe@tanga.com>:


On Sat, Jan 24, 2015 at 10:12 PM, Pavel Stehule <p= avel.stehule@gmail.com> wrote:
Hi

this plan= looks well

Regards

Pavel=

Here's = one that's not quite as well: http://explain.depesz.com/s/SgT
<= /div>

I see a possible issue

= (product_id <> '81716'::citext) .. this operation is CPU exp= ensive and maybe nonsense

product_id should be integer -= - and if it isn't - it should not be on 4M rows extremly fast - mainly = on citext

try to force a opposite cast - you will safe a= case insensitive text comparation

product_id::int <&g= t; 81716

It might not always be an integer, just happens to be so here. Should I tr= y text instead? I don't have to have the case-insensitive matching.

text can be better
=
this design is unhappy, but you cannot to change ot probably=

=C2=A0
<= font color=3D"#888888">

Joe
=C2=A0

Regards

<= font color=3D"#888888">
Pavel

=C2=A0
<= span>

Joe
=C2=A0
<= div dir=3D"ltr">

2015-01-25 6:45 = GMT+01:00 Joe Van Dyk <joe@tanga.com>:
Oops, didn't run vacuum an= alyze after deleting the events. Here is another 'explain analyze':= =C2=A0http:/= /explain.depesz.com/s/AviN

On Sat, Jan 24, 2015 at 9:43 PM, Joe Van D= yk <joe@tanga.com> wrote:
On Sat, Jan 24, 2015 at 9:41 PM, Joe Van Dyk <joe@tanga.c= om> wrote:
I have an events table that records page views and= purchases (type =3D 'viewed' or type=3D'purchased'). I hav= e a query that figures out "people who bought/viewed this also bought/= viewed that".

It worked fine, taking about 0.= 1 seconds to complete, until a few hours ago when it started taking hours t= o complete. Vacuum/analyze didn't help.=C2=A0 Turned out there was one = session_id that had 400k rows in the system. Deleting that made the query p= erformant again.=C2=A0

Is there anything I can do = to make the query work better in cases like that? Missing index, or better = query?

This is on 9.3.5.

The b= elow is reproduced at the following URL if it's not formatted correctly= in the email. https://gist.githubusercontent.com/joevandyk/cb8f4afdb6= c1b178c606/raw/9940bbe033ebd56d38caa46e33c1ddfd9df36eda/gistfile1.txt
explain  select
   e1.product_id,
   e2.site_id,
   e2.product_id,
   count(nullif(e2.type=3D'viewed', false)) view_count,
   count(nullif(e2.type=3D'purchased', false)) purchase_count
 from events e1
 join events e2 on e1.session_id =3D e2.session_id and e1.type =3D e2.type
 where
   e1.product_id =3D '82503' and
   e1.product_id !=3D e2.product_id
 group by e1.product_id, e2.product_id, e2.site_id;
                                                         QUERY PLAN
---------------------------------------------------------------------------=
-------------------------------------------------
 GroupAggregate  (cost=3D828395.67..945838.90 rows=3D22110 width=3D19)
   ->  Sort  (cost=3D828395.67..840117.89 rows=3D4688885 width=3D19)
         Sort Key: e1.product_id, e2.product_id, e2.site_id
         ->  Nested Loop  (cost=3D11.85..20371.14 rows=3D4688885 width=
=3D19)
               ->  Bitmap Heap Scan on events e1  (cost=3D11.29..1404.31=
 rows=3D369 width=3D49)
                     Recheck Cond: (product_id =3D '82503'::citext)
                     ->  Bitmap Index Scan on events_product_id_site_id_=
idx  (cost=3D0.00..11.20 rows=3D369 width=3D0)
                           Index Cond: (product_id =3D '82503'::cit=
ext)
               ->  Index Scan using events_session_id_type_product_id_id=
x on events e2  (cost=3D0.56..51.28 rows=3D12 width=3D51)
                     Index Cond: ((session_id =3D e1.session_id) AND (type =
=3D e1.type))
                     Filter: (e1.product_id <> product_id)
(11 rows)

recommender_production=3D> \d events
                                    Table "public.events"
   Column    |           Type           |                      Modifiers
-------------+--------------------------+----------------------------------=
-------------------
 id          | bigint                   | not null default nextval('eve=
nts_id_seq'::regclass)
 user_id     | citext                   |
 session_id  | citext                   | not null
 product_id  | citext                   | not null
 site_id     | citext                   | not null
 type        | text                     | not null
 happened_at | timestamp with time zone | not null
 created_at  | timestamp with time zone | not null
Indexes:
    "events_pkey" PRIMARY KEY, btree (id)
    "events_product_id_site_id_idx" btree (product_id, site_id)
    "events_session_id_type_product_id_idx" btree (session_id, ty=
pe, product_id)
Check constraints:
    "events_session_id_check" CHECK (length(session_id::text) <=
; 255)
    "events_type_check" CHECK (type =3D ANY (ARRAY['purchased=
'::text, 'viewed'::text]))
    "events_user_id_check" CHECK (length(user_id::text) < 255)=



After r= emoving the session with 400k events, I was able to do an explain analyze, = here is one of them:






--047d7b339d416504e6050d757758-- From tomas.vondra@2ndquadrant.com Sun Jan 25 16:57:48 2015 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YFQVQ-0002FZ-N7 for pgsql-performance@arkaria.postgresql.org; Sun, 25 Jan 2015 16:57:48 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YFQVQ-0000y2-2R for pgsql-performance@arkaria.postgresql.org; Sun, 25 Jan 2015 16:57:48 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YFQVN-0000xt-SC for pgsql-performance@postgresql.org; Sun, 25 Jan 2015 16:57:46 +0000 Received: from mail-wg0-f42.google.com ([74.125.82.42]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YFQVK-0002ko-6v for pgsql-performance@postgresql.org; Sun, 25 Jan 2015 16:57:43 +0000 Received: by mail-wg0-f42.google.com with SMTP id x13so5409495wgg.1 for ; Sun, 25 Jan 2015 08:57:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:organization:user-agent :mime-version:to:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=7mcqLqveFXg/rQyxr6G7m3eYvnDI+ZbEpdUNEZn3VC0=; b=IJ0j9jTFk0Cxz9AABx3j+H4fmaTfqdoHIaQ9Fr/tqp7Mx0DPnNHYv+lpZo2H/QwV+5 N5r38qMU7KtTCKwrbI/NL6/I+MysTCceOrq2cC8SXJKs1upveGV3e0z7XE7O81NmVfvQ aXshJbsmFxwIiJzrQivqN2Jri5ktNmL7CCRy4BIDdoZpd74axb/Ra98X7fyeYawHYyLO AeA6bdEqINjW4FqsgSdMy+fVbHbfE//LDfOkEPteUv9IrQK1h9ZKqTWH/MoesAjjdytp bxqxa+aI/a/RErFKsdBzD/KBTrHdPbaaD1pR8G7tlkzE34+jQ6aW4t7171GLIOUy/AIg YOEg== X-Gm-Message-State: ALoCoQn3F1SZMikAP5VhI1SiyYguDVBKHIMy3pVNVWWTlsiouO50BTtk7JSWR+/cks2vNg8NLxL+xKybDSabHQRt15gd8UcQ9b1Wl6/do4+gT01BA/hmnALlSdpJkbKdY1yACei6fFrvTlDz6tlYxMJnqTLunYWSSqAIr9ayIC1bG4jBkgfSwMrNtSBZYebUWgOmEdqrjiPb X-Received: by 10.194.189.138 with SMTP id gi10mr36643546wjc.86.1422205059725; Sun, 25 Jan 2015 08:57:39 -0800 (PST) Received: from [192.168.1.163] (ip-78-45-139-138.net.upcbroadband.cz. [78.45.139.138]) by mx.google.com with ESMTPSA id cf12sm10829982wjb.10.2015.01.25.08.57.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Jan 2015 08:57:39 -0800 (PST) Message-ID: <54C52080.90708@2ndquadrant.com> Date: Sun, 25 Jan 2015 17:57:36 +0100 From: Tomas Vondra Organization: 2ndQuadrant User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Query performance References: In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Hi, On 25.1.2015 07:38, Joe Van Dyk wrote: > > Here's one that's not quite as well: http://explain.depesz.com/s/SgT As Pavel already pointed out, the first problem is this part of the plan: Seq Scan on events e2 (cost=0.00..120,179.60 rows=4,450,241 width=51) (actual time=0.014..33,773.370 rows=4,450,865 loops=1) Filter: (product_id <> '81716'::citext) Consuming ~33 seconds of the runtime. If you can make this faster somehow (e.g. by getting rid of the citext cast), that'd be nice. Another issue is that the hashjoin is batched: Buckets: 65536 Batches: 8 Memory Usage: 46085kB The hash preparation takes ~40 seconds, so maybe try to give it a bit more memory - I assume you have work_mem=64MB, so try doubling that (ISTM 512MB should work with a single batch). Maybe this won't really improve the performance, though. It still has to process ~4.5M rows. Increasing the work mem could also result in switching to hash aggregate, making the sort (~30 seconds) unnecessary. Anyway, ISTM this works as expected, i.e. (a) with rare product_id values the queries are fast (b) with common product_id values the queries are slow That's expected, because (b) needs to process much more data. I don't think you can magically make it run as fast as (a). The best solution might be to keep a pre-aggregated results - I don't think you really need exact answers when recommending "similar" products. I also wonder if you really need to join the tables? I mean, what if you do something like this: CREATE TABLE events_aggregated AS SELECT site_id, array_agg(product_id) AS product_ids, count(nullif(e2.type='viewed', false)) view_count, count(nullif(e2.type='purchased', false)) purchase_count FROM events GROUP BY 1; and then using intarray with GIN indexes to query this table? Something like this: CREATE products_agg_idx ON aggregated USING GIN (product_ids gin__int_ops); SELECT * FROM events_aggregated WHERE product_ids @> ARRAY['82503']; regards -- Tomas Vondra http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance From M.Mamin@intershop.de Sun Jan 25 21:07:22 2015 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YFUOw-0004j8-6r for pgsql-performance@arkaria.postgresql.org; Sun, 25 Jan 2015 21:07:22 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YFUOv-0000BT-4s for pgsql-performance@arkaria.postgresql.org; Sun, 25 Jan 2015 21:07:21 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YFUOt-0000BJ-K7 for pgsql-performance@postgresql.org; Sun, 25 Jan 2015 21:07:19 +0000 Received: from mailrelay.intershop.de ([195.110.60.9]) by makus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YFUOo-0007GQ-Qk for pgsql-performance@postgresql.org; Sun, 25 Jan 2015 21:07:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intershop.de; h= mime-version:content-type:content-type:content-language :accept-language:in-reply-to:references:message-id:date:date :subject:subject:from:from:received; s=20130906; t=1422220030; x=1424034431; bh=cTWTjdZHYybv86wjtFF/85CTaag6v96geGuSkGe1CT8=; b= XvUXY1A8pAlOwY+YYIA4nFMJMpoY7v/glvl2SEAOCUp9fu65yI1FRf9kiJ7ZxaWF 0b679sU8WN31n6Ib5al0xmgFgoxJQEWWVWjM+Ulcz2fWr5i+JRuyJjss3s4wagaH zCeA9701RoeufTFtHcc9lx63vMaVP7kqBeYQrqRpUkOv9eWkIMTRHkylgxuqFUFk EnoJlHLTPmAExLdEwlpd10T4e2eUj/zbWCgKdhaoNlih7sjQT8tBEWtssv13Vpcj TpczJyouhSgff/M9ytEoP9obaEzgTaZm77rSAWhEfGSLsiPDP3RMCIA4STdSfljq xwlNnVccYzo1S20Tcrkn1g== X-Virus-Scanned: amavisd-new at intershop.de Received: from JENCAS01.ad.intershop.net ([10.0.87.63]) by mailrelay.intershop.de (8.14.9/8.14.7) with ESMTP id t0PL78d6001743; Sun, 25 Jan 2015 22:07:10 +0100 Received: from jenmbs01.ad.intershop.net ([fe80::4d04:5c70:c5d6:d5a1]) by JENCAS01.ad.intershop.net ([fe80::a45c:8522:37f2:3a34%11]) with mapi id 14.03.0224.002; Sun, 25 Jan 2015 22:07:07 +0100 From: Marc Mamin To: Joe Van Dyk , "pgsql-performance@postgresql.org" Subject: Re: Query performance Thread-Topic: [PERFORM] Query performance Thread-Index: AQHQOGGudoamHrXqd0uBvz7sFPZvlZzRVM9v Date: Sun, 25 Jan 2015 21:07:06 +0000 Message-ID: References: In-Reply-To: Accept-Language: de-DE, en-US Content-Language: de-DE X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.0.130.3] Content-Type: multipart/alternative; boundary="_000_B6F6FD62F2624C4C9916AC0175D56D8828B452AAjenmbs01adinter_" MIME-Version: 1.0 X-Pg-Spam-Score: -4.3 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org --_000_B6F6FD62F2624C4C9916AC0175D56D8828B452AAjenmbs01adinter_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable >I have an events table that records page views and purchases (type =3D 'vi= ewed' or type=3D'purchased'). I have a query that figures out "people who b= ought/viewed this also bought/viewed that". > >It worked fine, taking about 0.1 seconds to complete, until a few hours ag= o when it started taking hours to complete. Vacuum/analyze didn't help. Tu= rned out there was one session_id that had 400k rows in the system. Deletin= g that made the query performant again. > >Is there anything I can do to make the query work better in cases like tha= t? Missing index, or better query? > >This is on 9.3.5. > >The below is reproduced at the following URL if it's not formatted correct= ly in the email. https://gist.githubusercontent.com/joevandyk/cb8f4afdb6c1b= 178c606/raw/9940bbe033ebd56d38caa46e33c1ddfd9df36eda/gistfile1.txt Hello, here are 2 variations that should be somewhat faster. It seems you may have duplicate (site_id,session_id,product_id) which would false the result. In that case you'll need some more logic in = the query. select '82503' as product_id, e2.site_id, e2.product_id, count(nullif(e2.type=3D'viewed', false)) view_count, count(nullif(e2.type=3D'purchased', false)) purchase_count from events e1 join events e2 on e1.session_id =3D e2.session_id and e1.type =3D e2.type where e1.product_id =3D '82503' and e2.product_id !=3D '82503' group by e2.product_id, e2.site_id; OR: WITH SALL as( select e2.site_id, e2.product_id, count(nullif(e2.type=3D'viewed', false)) view_count, count(nullif(e2.type=3D'purchased', false)) purchase_count from events e1 join events e2 on e1.session_id =3D e2.session_id and e1.type =3D e2.typ= e where e1.product_id =3D '82503' group by e2.product_id, e2.site_id ) SELECT '82503' as product_id_1, site_id, product_id, view_count, purchase_count FROM SALL WHERE product_id !=3D '82503'; regards, Marc Mamin >explain select > e1.product_id, > e2.site_id, > e2.product_id, > count(nullif(e2.type=3D'viewed', false)) view_count, > count(nullif(e2.type=3D'purchased', false)) purchase_count > from events e1 > join events e2 on e1.session_id =3D e2.session_id and e1.type =3D e2.type > where > e1.product_id =3D '82503' and > e1.product_id !=3D e2.product_id > group by e1.product_id, e2.product_id, e2.site_id; > QUERY PLAN >--------------------------------------------------------------------------= -------------------------------------------------- > GroupAggregate (cost=3D828395.67..945838.90 rows=3D22110 width=3D19) > -> Sort (cost=3D828395.67..840117.89 rows=3D4688885 width=3D19) > Sort Key: e1.product_id, e2.product_id, e2.site_id > -> Nested Loop (cost=3D11.85..20371.14 rows=3D4688885 width=3D1= 9) > -> Bitmap Heap Scan on events e1 (cost=3D11.29..1404.31 r= ows=3D369 width=3D49) > Recheck Cond: (product_id =3D '82503'::citext) > -> Bitmap Index Scan on events_product_id_site_id_id= x (cost=3D0.00..11.20 rows=3D369 width=3D0) > Index Cond: (product_id =3D '82503'::citext) > -> Index Scan using events_session_id_type_product_id_idx = on events e2 (cost=3D0.56..51.28 rows=3D12 width=3D51) > Index Cond: ((session_id =3D e1.session_id) AND (type= =3D e1.type)) > Filter: (e1.product_id <> product_id) >(11 rows) > >recommender_production=3D> \d events > Table "public.events" > Column | Type | Modifiers >-------------+--------------------------+---------------------------------= -------------------- > id | bigint | not null default nextval('events= _id_seq'::regclass) > user_id | citext | > session_id | citext | not null > product_id | citext | not null > site_id | citext | not null > type | text | not null > happened_at | timestamp with time zone | not null > created_at | timestamp with time zone | not null >Indexes: > "events_pkey" PRIMARY KEY, btree (id) > "events_product_id_site_id_idx" btree (product_id, site_id) > "events_session_id_type_product_id_idx" btree (session_id, type, produ= ct_id) >Check constraints: > "events_session_id_check" CHECK (length(session_id::text) < 255) > "events_type_check" CHECK (type =3D ANY (ARRAY['purchased'::text, 'vie= wed'::text])) > "events_user_id_check" CHECK (length(user_id::text) < 255) > > > > --_000_B6F6FD62F2624C4C9916AC0175D56D8828B452AAjenmbs01adinter_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

>I have an events table that records page views and purchases (type =3D = 'viewed' or type=3D'purchased'). I have a query that figures out "peop= le who bought/viewed this also bought/viewed that".
>
>It worked fine, taking about 0.1 seconds to complete, until a few hours= ago when it started taking hours to complete. Vacuum/analyze didn't help.&= nbsp; Turned out there was one session_id that had 400k rows in the system.= Deleting that made the query performant again.
>
>Is there anything I can do to make the query work better in cases like = that? Missing index, or better query?
>
>This is on 9.3.5.
>
>The below is reproduced at the following URL if it's not formatted corr= ectly in the email. https://gist.githubusercontent.com/joevandyk/cb8f4afdb6= c1b178c606/raw/9940bbe033ebd56d38caa46e33c1ddfd9df36eda/gistfile1.txt

Hello,

here  are 2 variations that should be somewhat faster.

 It seems you may have duplicate (site_id,session_id,product_id)
 which would false the result. In that case you'll need some more logi= c in the query.
 
 select
    '82503' as product_id,
    e2.site_id,
    e2.product_id,
    count(nullif(e2.type=3D'viewed', false)) view_count,
    count(nullif(e2.type=3D'purchased', false)) purchase_cou= nt
  from events e1
  join events e2 on e1.session_id =3D e2.session_id and e1.type =3D e2= .type
  where
    e1.product_id =3D '82503' and
    e2.product_id !=3D '82503'
 group by  e2.product_id, e2.site_id;
 
 
 OR:
 
 WITH SALL as(
  select
     e2.site_id,
     e2.product_id,
     count(nullif(e2.type=3D'viewed', false)) view_coun= t,
     count(nullif(e2.type=3D'purchased', false)) purcha= se_count
   from events e1
   join events e2 on e1.session_id =3D e2.session_id and e1.type = =3D e2.type
   where
     e1.product_id =3D '82503'
  group by  e2.product_id, e2.site_id
 )
 SELECT
    '82503' as product_id_1,
    site_id,
    product_id,
    view_count,
    purchase_count
 FROM SALL
 WHERE product_id !=3D '82503';
    

 regards,
 Marc Mamin
 


>explain  select
>   e1.product_id,
>   e2.site_id,
>   e2.product_id,
>   count(nullif(e2.type=3D'viewed', false)) view_count,
>   count(nullif(e2.type=3D'purchased', false)) purchase_count=
> from events e1
> join events e2 on e1.session_id =3D e2.session_id and e1.type =3D e2.t= ype
> where
>   e1.product_id =3D '82503' and
>   e1.product_id !=3D e2.product_id
> group by e1.product_id, e2.product_id, e2.site_id;
>            = ;            &n= bsp;            = ;            &n= bsp;       QUERY PLAN
>-----------------------------------------------------------------------= -----------------------------------------------------
> GroupAggregate  (cost=3D828395.67..945838.90 rows=3D22110 width= =3D19)
>   ->  Sort  (cost=3D828395.67..840117.89 rows= =3D4688885 width=3D19)
>         Sort Key: e1.product_i= d, e2.product_id, e2.site_id
>         ->  Nested Loo= p  (cost=3D11.85..20371.14 rows=3D4688885 width=3D19)
>            = ;   ->  Bitmap Heap Scan on events e1  (cost=3D11.29= ..1404.31 rows=3D369 width=3D49)
>            = ;         Recheck Cond: (product_id= =3D '82503'::citext)
>            = ;         ->  Bitmap Index = Scan on events_product_id_site_id_idx  (cost=3D0.00..11.20 rows=3D369 = width=3D0)
>            = ;            &n= bsp;  Index Cond: (product_id =3D '82503'::citext)
>            = ;   ->  Index Scan using events_session_id_type_product_i= d_idx on events e2  (cost=3D0.56..51.28 rows=3D12 width=3D51)
>            = ;         Index Cond: ((session_id = =3D e1.session_id) AND (type =3D e1.type))
>            = ;         Filter: (e1.product_id &l= t;> product_id)
>(11 rows)
>
>recommender_production=3D> \d events
>            = ;            &n= bsp;           Table &quo= t;public.events"
>   Column    |     &n= bsp;     Type       =     |         &= nbsp;            Mod= ifiers
>-------------+--------------------------+----------------------= -------------------------------
> id          | bigint = ;            &n= bsp;     | not null default nextval('events_id_seq'::re= gclass)
> user_id     | citext     =             &nb= sp; |
> session_id  | citext       &nb= sp;           | not null<= br> > product_id  | citext       &nb= sp;           | not null<= br> > site_id     | citext     =             &nb= sp; | not null
> type        | text   = ;            &n= bsp;     | not null
> happened_at | timestamp with time zone | not null
> created_at  | timestamp with time zone | not null
>Indexes:
>    "events_pkey" PRIMARY KEY, btree (id)
>    "events_product_id_site_id_idx" btree (pro= duct_id, site_id)
>    "events_session_id_type_product_id_idx" bt= ree (session_id, type, product_id)
>Check constraints:
>    "events_session_id_check" CHECK (length(se= ssion_id::text) < 255)
>    "events_type_check" CHECK (type =3D ANY (A= RRAY['purchased'::text, 'viewed'::text]))
>    "events_user_id_check" CHECK (length(user_= id::text) < 255)
>
>
>
>
--_000_B6F6FD62F2624C4C9916AC0175D56D8828B452AAjenmbs01adinter_-- From Jim.Nasby@BlueTreble.com Sat Jan 31 01:40:35 2015 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YHN34-00083e-V0 for pgsql-performance@arkaria.postgresql.org; Sat, 31 Jan 2015 01:40:35 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YHN34-00039T-AO for pgsql-performance@arkaria.postgresql.org; Sat, 31 Jan 2015 01:40:34 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YHN33-00039L-3u for pgsql-performance@postgresql.org; Sat, 31 Jan 2015 01:40:33 +0000 Received: from mail-bn1bon0653.outbound.protection.outlook.com ([2a01:111:f400:fc10::1:653] helo=na01-bn1-obe.outbound.protection.outlook.com) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YHN2z-0001dA-2w for pgsql-performance@postgresql.org; Sat, 31 Jan 2015 01:40:31 +0000 Received: from decina.local (24.55.12.91) by CY1PR11MB0345.namprd11.prod.outlook.com (25.161.165.13) with Microsoft SMTP Server (TLS) id 15.1.65.19; Sat, 31 Jan 2015 01:40:22 +0000 Message-ID: <54CC327D.6000202@BlueTreble.com> Date: Fri, 30 Jan 2015 19:40:13 -0600 From: Jim Nasby User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Pavel Stehule , Joe Van Dyk CC: "pgsql-performance@postgresql.org" Subject: Re: Query performance References: In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [24.55.12.91] X-ClientProxiedBy: DM2PR10CA0081.namprd10.prod.outlook.com (10.141.241.49) To CY1PR11MB0345.namprd11.prod.outlook.com (25.161.165.13) Authentication-Results: postgresql.org; dkim=none (message not signed) header.d=none; X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:CY1PR11MB0345; X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004); SRVR:CY1PR11MB0345; X-Forefront-PRVS: 0473A03F3F X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(479174004)(377454003)(51704005)(24454002)(50466002)(23676002)(62966003)(77156002)(47776003)(59896002)(76176999)(65806001)(50986999)(54356999)(2950100001)(86362001)(46102003)(87266999)(15975445007)(64126003)(65816999)(93886004)(42186005)(33656002)(36756003)(65956001)(66066001)(92566002)(83506001)(122386002)(87976001)(19580395003)(40100003)(85282002)(336755003)(18886065003); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR11MB0345; H:decina.local; FPR:; SPF:None; MLV:sfv; LANG:en; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:;SRVR:CY1PR11MB0345; X-OriginatorOrg: bluetreble.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2015 01:40:22.0730 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR11MB0345 X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org On 1/25/15 2:03 AM, Pavel Stehule wrote: > It might not always be an integer, just happens to be so here. > Should I try text instead? I don't have to have the case-insensitive > matching. > > > text can be better bytea would be even better yet, because that will always be a straight binary comparison. text will worry about conversion and what not (though, perhaps there's a way to force that to use C or SQL instead of something like UTF8, short of changing the encoding of the whole database). -- Jim Nasby, Data Architect, Blue Treble Consulting Data in Trouble? Get it in Treble! http://BlueTreble.com -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance From pavel.stehule@gmail.com Sat Jan 31 06:28:55 2015 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YHRY7-00043M-6h for pgsql-performance@arkaria.postgresql.org; Sat, 31 Jan 2015 06:28:55 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YHRY6-0007mv-Gm for pgsql-performance@arkaria.postgresql.org; Sat, 31 Jan 2015 06:28:54 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YHRY4-0007mn-TW for pgsql-performance@postgresql.org; Sat, 31 Jan 2015 06:28:53 +0000 Received: from mail-pa0-x22a.google.com ([2607:f8b0:400e:c03::22a]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YHRY1-0006ni-If for pgsql-performance@postgresql.org; Sat, 31 Jan 2015 06:28:50 +0000 Received: by mail-pa0-f42.google.com with SMTP id bj1so60924734pad.1 for ; Fri, 30 Jan 2015 22:28:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=He+oP/FlabhE8h9wipKSi/NeqrRHNSQReGHI0s4euxw=; b=M/EGdW5FE/BEN6Vuoz1+QG121jVVCLyTHCaYv4nq2wK1NN/khaEbBk9xpkRSfRlz4z NFitamlH0tM5bHJ8vD4/h8mcBoyMp+StytMvwdcY3yT32PHMvJtxM7IsRXVwyFrsEjcF 4D2exT+ZBJllvSsK1fMJl6sOrLVPODX+0m41OfEEQDgJgBWGBu0iaCMGxO5sISlc7uRm L35L0kwWZCfayc0j72lOOXIHT7SJGRCZUxAB3nrX5fG/aRI89cvEsZjNPvhVHSY7zinQ UNDWDtWjXQ2lKBCF4XfhzDclwYu9z/9dkbT1b4vF/7cG8mJdSTsPgC9bJ3MNlJ+JWsBo Rb4g== X-Received: by 10.68.168.164 with SMTP id zx4mr13754958pbb.117.1422685728167; Fri, 30 Jan 2015 22:28:48 -0800 (PST) MIME-Version: 1.0 Received: by 10.70.120.70 with HTTP; Fri, 30 Jan 2015 22:28:08 -0800 (PST) In-Reply-To: <54CC327D.6000202@BlueTreble.com> References: <54CC327D.6000202@BlueTreble.com> From: Pavel Stehule Date: Sat, 31 Jan 2015 07:28:08 +0100 Message-ID: Subject: Re: Query performance To: Jim Nasby Cc: Joe Van Dyk , "pgsql-performance@postgresql.org" Content-Type: multipart/alternative; boundary=047d7b86d654745f3b050decd505 X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org --047d7b86d654745f3b050decd505 Content-Type: text/plain; charset=UTF-8 2015-01-31 2:40 GMT+01:00 Jim Nasby : > On 1/25/15 2:03 AM, Pavel Stehule wrote: > >> It might not always be an integer, just happens to be so here. >> Should I try text instead? I don't have to have the case-insensitive >> matching. >> >> >> text can be better >> > > bytea would be even better yet, because that will always be a straight > binary comparison. text will worry about conversion and what not (though, > perhaps there's a way to force that to use C or SQL instead of something > like UTF8, short of changing the encoding of the whole database). > true, good idea Regards Pavel > -- > Jim Nasby, Data Architect, Blue Treble Consulting > Data in Trouble? Get it in Treble! http://BlueTreble.com > --047d7b86d654745f3b050decd505 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
--047d7b86d654745f3b050decd505-- From diegov@propaas.com Mon Feb 20 21:39:52 2017 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cfviO-0007Qk-By for pgsql-performance@arkaria.postgresql.org; Mon, 20 Feb 2017 21:41:48 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cfviN-0000Z0-Hi for pgsql-performance@arkaria.postgresql.org; Mon, 20 Feb 2017 21:41:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cfvgf-00068f-PF for pgsql-performance@postgresql.org; Mon, 20 Feb 2017 21:40:01 +0000 Received: from mail-oi0-x229.google.com ([2607:f8b0:4003:c06::229]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1cfvga-0004Ai-1z for pgsql-performance@postgresql.org; Mon, 20 Feb 2017 21:40:00 +0000 Received: by mail-oi0-x229.google.com with SMTP id y140so28802448oie.1 for ; Mon, 20 Feb 2017 13:39:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=propaas-com.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=cXKMvUcOOrQGxU5b1gYGkWaUSzxeu3suJ2szf48WBXA=; b=i7u50qrdKXsiQcu6nS+sQKbNSiFA0RIJ6L+Qg7Ua/+57Q0AFIEtRerYHN+CoTPq5F4 D+ShvtU51a9TZYrHmrKo0aNMUDbelBz+hIu2T7Bf4qKbiQfKBJXXJWb+QdhePiH/HA/W FjyZSG+90btGlNjjP+SadO5zqN+qRZpk0Djp3g+jJ1jQoU/G3jNGCrw7UuesnVKj9tDB 6rjeICuRHVKoFiIxmwEJVCL/I1/1aIww8eIKKERTH5zewHtN2ZvDbdD+u2cqaBqSrkQO rfL4qrME0FPANC/+5I9rvjXqmTnuzoSUZJgJdcnBuByor5t1SDqtTJdwnadh/wemU4UZ Pm8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=cXKMvUcOOrQGxU5b1gYGkWaUSzxeu3suJ2szf48WBXA=; b=tTMJgL5s8aI+1slJ7MJhsssJvDWqF75aTobR520imJRP6NJIeQZOstrIS8XxqxAfLl 3SjjH3cliFEQTRQ8id5VR1130BajPs7HHi/M+ANauKmSsX1tNqN+s6VwQB1rFzJBaYR6 0MMRIDD9LY/rIDneyA70TGZElkND7M1WI6oihP+j19wxRIsDqr050h3wMqiKt3EcrH7P pmHxLfPbo2Nk79SZPg5d7gXx5h14wrMDk1VeDNEVesc9M5QNDN2KSyr1wbQfEb78Xndp MnXtJLGCqtitzNdKO6+58FB3DHRAyuICje5CmwcQbzRhobvxxC9S+0UpijutRaJIB5Os GQUA== X-Gm-Message-State: AMke39lT6k1AfnO+FK2BIxIuwwQMdwhXR96R7vArhCEfLr9fM1EKrvKEJUmB/p492fRidD3wmeefIiFbQyhMqQ== X-Received: by 10.202.71.205 with SMTP id u196mr1310560oia.205.1487626793416; Mon, 20 Feb 2017 13:39:53 -0800 (PST) MIME-Version: 1.0 Received: by 10.157.17.146 with HTTP; Mon, 20 Feb 2017 13:39:52 -0800 (PST) From: Diego Vargas Date: Mon, 20 Feb 2017 16:39:52 -0500 Message-ID: Subject: Query Performance To: pgsql-performance@postgresql.org Content-Type: multipart/alternative; boundary=001a113e513294a47b0548fd1ab1 X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org --001a113e513294a47b0548fd1ab1 Content-Type: text/plain; charset=UTF-8 Hi All, I'm having some trouble improving the timing of a set of queries to a partitioned table. Basically, I'm trying to find an index that would be used instead of a bitmap heap scan by when the data is taken from disk. Or in any case, something that would make the process of retrieving the data from disk faster. I've installed postgreSQL compiling the source: PostgreSQL 9.2.20 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-17), 64-bit And these are the current changes on the configuration file: name | current_setting | source ----------------------------+--------------------+---------------------- application_name | psql | client client_encoding | UTF8 | client DateStyle | ISO, MDY | configuration file default_text_search_config | pg_catalog.english | configuration file lc_messages | en_US.UTF-8 | configuration file lc_monetary | en_US.UTF-8 | configuration file lc_numeric | en_US.UTF-8 | configuration file lc_time | en_US.UTF-8 | configuration file log_destination | stderr | configuration file log_directory | pg_log | configuration file log_filename | postgresql-%a.log | configuration file log_rotation_age | 1d | configuration file log_rotation_size | 0 | configuration file log_timezone | UTC | configuration file log_truncate_on_rotation | on | configuration file logging_collector | on | configuration file max_connections | 100 | configuration file max_stack_depth | 2MB | environment variable shared_buffers | 6GB | configuration file TimeZone | UTC | configuration file work_mem | 50MB | configuration file I'm running on CentOS 6.8, and all the tests are being done through psql. Now, this is the table in question: lportal=# \d+ data_jsons_partition Table "data_jsons_partition" Column | Type | Modifiers | Storage | Stats target | Description -----------------+-----------------------------+-----------+ ----------+--------------+------------- id | integer | | plain | | site_id | integer | | plain | | site_name | character varying(255) | | extended | | measured_on | date | | plain | | protocol | text | | extended | | data | json | | extended | | created_at | timestamp without time zone | | plain | | updated_at | timestamp without time zone | | plain | | org_name | character varying | | extended | | org_id | integer | | plain | | lat | double precision | | plain | | long | double precision | | plain | | elev | double precision | | plain | | Triggers: insert_measurement_trigger BEFORE INSERT ON data_jsons_partition FOR EACH ROW EXECUTE PROCEDURE data_insert_trigger() Child tables: partitions.partition_a_data_jsons_part, partitions.partition_b_data_jsons_part, ... partitions.partition_aa_data_jsons_part, partitions.partition_ab_data_jsons_part The child tables exists based on the protocol column. Now, each partition looks like this: lportal=# \d+ partitions.partition_ab_data_jsons_part Table "partitions.partition_ab_data_jsons_part" Column | Type | Modifiers | Storage | Stats target | Description -----------------+-----------------------------+-----------+ ----------+--------------+------------- id | integer | not null | plain | | site_id | integer | | plain | | site_name | character varying(255) | | extended | | measured_on | date | | plain | | protocol | text | | extended | | data | json | | extended | | created_at | timestamp without time zone | | plain | | updated_at | timestamp without time zone | | plain | | org_name | character varying | | extended | | organization_id | integer | | plain | | latitude | double precision | | plain | | longitude | double precision | | plain | | elevation | double precision | | plain | | Indexes: "partition_ab_data_jsons_part_pkey" PRIMARY KEY, btree (id) "partition_ab_data_jsons_part_spm_key" UNIQUE CONSTRAINT, btree (site_id, protocol, measured_on) "partition_ab_data_jsons_part_mo" btree (measured_on) "partition_ab_data_jsons_part_org" btree (org_name) "partition_ab_data_jsons_part_org_id" btree (organization_id) "partition_ab_data_jsons_part_sid" btree (site_id) CLUSTER "partition_ab_data_jsons_part_sm" btree (site_id, measured_on) Check constraints: "partition_ab_data_jsons_part_protocol_check" CHECK (protocol = ' partition_ab'::text) Inherits: data_jsons_partition Now, I have this query that I've executed with a clean cache: lportal=# explain analyze SELECT org_name, site_name, latitude, longitude, elevation, measured_on, data FROM data_jsons_partition where protocol in ('aerosols','precipitations') and site_id in (... around 1000 site_id-s ...) and (measured_on >= '2013-09-24' and measured_on <= '2016-10-10') order by org_name, site_name, measured_on limit 1000000; And I get the following: Limit (cost=149414.00..149518.52 rows=41806 width=110) (actual time=25827.893..26012.065 rows=126543 loops=1) -> Sort (cost=149414.00..149518.52 rows=41806 width=110) (actual time=25827.889..25970.671 rows=126543 loops=1) Sort Key: data_jsons_partition.org_name, data_jsons_partition.site_name, data_jsons_partition.measured_on Sort Method: external merge Disk: 70616kB -> Result (cost=0.00..146205.09 rows=41806 width=110) (actual time=38.533..20810.204 rows=126543 loops=1) -> Append (cost=0.00..146205.09 rows=41806 width=110) (actual time=38.530..20739.245 rows=126543 loops=1) -> Seq Scan on data_jsons_partition (cost=0.00..0.00 rows=1 width=608) (actual time=0.002..0.002 rows=0 loops=1) Filter: ((protocol = ANY ('{partition_a,partition_b}'::text[])) AND (measured_on >= '2013-09-24'::date) AND (measured_on <= '2016-10-10'::date) AND (site_id = ANY ('{... 1000 site_id-s ...}'::integer[]))) -> Bitmap Heap Scan on partition_a_data_jsons_part data_jsons_partition (cost=70.92..5209.38 rows=2132 width=114) (actual time=38.526..812.397 rows=3017 loops=1) Recheck Cond: ((measured_on >= '2013-09-24'::date) AND (measured_on <= '2016-10-10'::date)) Filter: ((protocol = ANY ('{partition_a, partition_b}'::text[])) AND (site_id = ANY ('{ ... }'::integer[]))) -> Bitmap Index Scan on partition_a _data_jsons_part_mo (cost=0.00..70.39 rows=3014 width=0) (actual time=2.974..2.974 rows=3017 loops=1) Index Cond: ((measured_on >= '2013-09-24'::date) AND (measured_on <= '2016-10-10'::date)) -> Bitmap Heap Scan on partition_b_data_jsons_part data_jsons_partition (cost=4582.19..140995.72 rows=39673 width=110) (actual time=738.486..19871.141 rows=123526 loops=1) Recheck Cond: ((site_id = ANY ('{... ...}'::integer[]))) Filter: (protocol = ANY ('{partition_a, partition_b}'::text[])) -> Bitmap Index Scan on partition_b _data_jsons_part_sm (cost=0.00..4572.27 rows=39673 width=0) (actual time=715.684..715.684 rows=123526 loops=1) Index Cond: ((site_id = ANY ('{... ...}'::integer[]))) Total runtime: 26049.062 ms From nagaraj.sf@yahoo.com Thu Oct 22 00:32:29 2020 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 1kVOXc-0005Te-Mk for pgsql-performance@arkaria.postgresql.org; Thu, 22 Oct 2020 00:33:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kVOX3-0001xG-KY for pgsql-performance@arkaria.postgresql.org; Thu, 22 Oct 2020 00:32:41 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kVOX3-0001x9-28 for pgsql-performance@lists.postgresql.org; Thu, 22 Oct 2020 00:32:41 +0000 Received: from sonic301-30.consmr.mail.ne1.yahoo.com ([66.163.184.199]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kVOWy-0003Yo-NX for pgsql-performance@lists.postgresql.org; Thu, 22 Oct 2020 00:32:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1603326752; bh=AUKWrmx0Ld/ZCIrzDFmLVIEx+IcaqT8q42oqmvnJPX8=; h=Date:From:To:Subject:References:From:Subject; b=JS+Q0QagM0sw0dbUaHqQEyK8MzLone0S3JHgEf+OHK5vmdKWK3symeMCi3ziMKYEZdWz8gloAA0ReZrOzShv5d6HNskifoQBuwoouXPfJA3mwxirm4ZQc2Z+e2qp6jzzzlLhN2/FOys8onSwInyWFsaTjwYQz8XBFoOwJOhl9XeOCScQstLtaOhQ5dtRsSDn16Hmha6mcPsp2NpC+RD74sWy+sFQQlWXqwQm/S4S979cgrgT+3vmQZGfP+X+jnNuWMPGpYaSDlE/gCyngtUuVwaCPWcYu+F+6CXBiqWjItEJHOg3Qz6TaIUeHiXCECJpqhYv9doIYlYTOv4rtCjIOQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1603326752; bh=sTpPu1+rbRj9QqQ5aJH5Qw+gXPUDoF4c8X1K44v385K=; h=Date:From:To:Subject; b=maNmtFsGTjDy+RBAzUv4RkO1nNOufW65EBlnvP1R/Igp2PiAKcOHzoqn0Ry05JxRuVtJNjf16J9kU9yPczH8lJuEupVgIM2GgaBCM+JMpxlV1N9vO+s+2FegvxCNnXMY09t/OaqHypaEcZ8dIkBq6stc5yYEiNn+fts2rtEWUaEkoSJwGxTLkVQndnVM4Gcw/fjU2QgXOVJce7PlATiQL/7QEzhgYmeZ+J3DW/TmU1t8j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BNyDgbrlNrM6Ie3hw2Kv_xLH_90vJ _Vlv3Tge_qNAdKMcORSJfHw7kTCHkqt8HxUEAPHUz1ihHWhMo26G5Zkbm71hSnZIUeNICJ3DuVdA XZ0DY79rE3W3sudyYocjvNhHTlWC8Snt9r21zkuSyW.A2Vn_.7g5T0Jx4pxn2761J5b4pgD1akJY cuUBpIb1i8q3SCBTpcDO8q8TY8UW5jAgWbuK5rjwhUVwUCi_d7jCb.PvPombUWjEu1PNIbRXjrl6 nW7bdJmmhfLUl.5PGE4uXWDUQe.gx9OvHRQjnxWiLKCGcKrHChINgp1tidzWl9eesA_0jSobz.WI hd1BET4Cdji_F6nVTqZbaIJbHb4ztU499DY39BpIHb.YyRzXkY6YAyM9zscUMP175rRlrzCLkAo5 i9rvN1.bKDmMRu4OhNBQxYigvE62LxK1u..LWo.kQqj4VjAHaHT6XZ1a95U5cDnOYbdagoRj7jMC 2t4OI7TlB2QN4lzp2uHeXrRPBZXauh_jwHZlOZ2SClJKxJ_dC5ueIsL2hnuV.uZ8D Received: from sonic.gate.mail.ne1.yahoo.com by sonic301.consmr.mail.ne1.yahoo.com with HTTP; Thu, 22 Oct 2020 00:32:32 +0000 Date: Thu, 22 Oct 2020 00:32:29 +0000 (UTC) From: Nagaraj Raj To: Pgsql Performance Message-ID: <2026306342.2139401.1603326749019@mail.yahoo.com> Subject: Query performance MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_2139400_360393687.1603326749015" References: <2026306342.2139401.1603326749019.ref@mail.yahoo.com> X-Mailer: WebService/1.1.16868 YMailNorrin Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.80 Safari/537.36 Content-Length: 28538 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------=_Part_2139400_360393687.1603326749015 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi, I have long running query which running for long time and its planner a= lways performing sequnce scan the table2.My gole is to reduce Read IO on th= e disk cause, this query runns=C2=A0more oftenly=C2=A0( using this in funti= on for ETL).=C2=A0 table1:=C2=A0transfer_order_header(records=C2=A02782678)table2:=C2=A0transf= er_order_item ( records: 15995697)here is the query: set work_mem =3D '688552kB';explain (analyze,buffers)select=C2=A0 =C2=A0 = =C2=A0COALESCE(itm.serialnumber,'') AS SERIAL_NO,=C2=A0=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 COALESCE(itm.ITEM_SKU,'') AS SKU,=C2=A0=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 COALESCE(itm.receivingplant,'') AS RECEIVINGPLA= NT,=C2=A0 COALESCE(itm.STO_ID,'') AS STO, supplyingplant,=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 COALESCE(itm.deliveryitem,'') AS DELIVERYITEM, =C2= =A0 =C2=A0 min(eventtime) as eventtime=C2=A0=C2=A0FROM sor_t.transfer_order= _header hed,sor_t.transfer_order_item itm=C2=A0=C2=A0where hed.eventid=3Dit= m.eventid group by 1,2,3,4,5,6 Query Planner[2]: "Finalize GroupAggregate (cost=3D1930380.06..4063262.11 rows=3D16004137 wid= th=3D172) (actual time=3D56050.500..83268.566 rows=3D15891873 loops=3D1)"" = Group Key: (COALESCE(itm.serialnumber, ''::character varying)), (COALESCE(i= tm.item_sku, ''::character varying)), (COALESCE(itm.receivingplant, ''::cha= racter varying)), (COALESCE(itm.sto_id, ''::character varying)), hed.supply= ingplant, (COALESCE(itm.deliveryitem, ''::character varying))"" Buffers: sh= ared hit=3D712191 read=3D3, temp read=3D38232 written=3D38233"" -> Gather M= erge (cost=3D1930380.06..3669827.09 rows=3D13336780 width=3D172) (actual ti= me=3D56050.488..77106.993 rows=3D15948520 loops=3D1)"" Workers Planned: 2""= Workers Launched: 2"" Buffers: shared hit=3D2213081 read=3D12, temp read= =3D142840 written=3D142843"" -> Partial GroupAggregate (cost=3D1929380.04..= 2129431.74 rows=3D6668390 width=3D172) (actual time=3D50031.458..54888.828 = rows=3D5316173 loops=3D3)"" Group Key: (COALESCE(itm.serialnumber, ''::char= acter varying)), (COALESCE(itm.item_sku, ''::character varying)), (COALESCE= (itm.receivingplant, ''::character varying)), (COALESCE(itm.sto_id, ''::cha= racter varying)), hed.supplyingplant, (COALESCE(itm.deliveryitem, ''::chara= cter varying))"" Buffers: shared hit=3D2213081 read=3D12, temp read=3D14284= 0 written=3D142843"" -> Sort (cost=3D1929380.04..1946051.01 rows=3D6668390 = width=3D172) (actual time=3D50031.446..52823.352 rows=3D5332010 loops=3D3)"= " Sort Key: (COALESCE(itm.serialnumber, ''::character varying)), (COALESCE(= itm.item_sku, ''::character varying)), (COALESCE(itm.receivingplant, ''::ch= aracter varying)), (COALESCE(itm.sto_id, ''::character varying)), hed.suppl= yingplant, (COALESCE(itm.deliveryitem, ''::character varying))"" Sort Metho= d: external merge Disk: 305856kB"" Worker 0: Sort Method: external merge Di= sk: 436816kB"" Worker 1: Sort Method: external merge Disk: 400048kB"" Buffe= rs: shared hit=3D2213081 read=3D12, temp read=3D142840 written=3D142843"" -= > Parallel Hash Join (cost=3D133229.66..603743.97 rows=3D6668390 width=3D17= 2) (actual time=3D762.925..3901.133 rows=3D5332010 loops=3D3)"" Hash Cond: = ((itm.eventid)::text =3D (hed.eventid)::text)"" Buffers: shared hit=3D22130= 27 read=3D12"" -> Parallel Seq Scan on transfer_order_item itm (cost=3D0.00= ..417722.90 rows=3D6668390 width=3D68) (actual time=3D0.005..524.359 rows= =3D5332010 loops=3D3)"" Buffers: shared hit=3D351039"" -> Parallel Hash (co= st=3D118545.68..118545.68 rows=3D1174718 width=3D35) (actual time=3D755.590= ..755.590 rows=3D926782 loops=3D3)"" Buckets: 4194304 Batches: 1 Memory Usa= ge: 243808kB"" Buffers: shared hit=3D1861964 read=3D12"" -> Parallel Index = Only Scan using transfer_order_header_eventid_supplyingplant_eventtime_idx1= on transfer_order_header hed (cost=3D0.56..118545.68 rows=3D1174718 width= =3D35) (actual time=3D0.128..388.436 rows=3D926782 loops=3D3)"" Heap Fetche= s: 18322"" Buffers: shared hit=3D1861964 read=3D12""Planning Time: 1.068 ms= ""Execution Time: 84274.004 ms" Tables[1]=C2=A0 created ddls in dbfiddle. PG Server:=C2=A0 PostgreSQL 11.7 on x86_64-pc-linux-gnu, compiled by gcc (G= CC) 4.9.3, 64-bit.RAM: 456Mem Settings:=C2=A0"maintenance_work_mem" "856371= 2" "kB" "work_mem" "688552" =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0"kB" "wal_buffers" =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0"2048"=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 "8kB" "shared_buffers" =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0"44388442"=C2=A0 =C2=A0 =C2=A0"8kB" Any suggestions would greatly appretiated.=C2=A0 Thanks,Rj ------=_Part_2139400_360393687.1603326749015 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi, I have long running query which running = for long time and its planner always performing sequnce scan the table2.My = gole is to reduce Read IO on the disk cause, this query runns more oft= enly ( using this in funtion for ETL). 


table1: transfer_order_header(records 2782678)
<= div dir=3D"ltr" data-setdir=3D"false">table2: transfer_order_item ( records: 15995697)
here is the query:

set work_m= em =3D '688552kB';
explain (analyze,buffers)
select&nbs= p;    COALESCE(itm.serialnumber,'') AS SERIAL_NO, 
            COALESCE(itm.ITEM_SKU,'') AS SKU= , 
            COALESCE(itm.re= ceivingplant,'') AS RECEIVINGPLANT, 
=09=09=09COALESCE(itm.STO_ID,'') AS STO,
<= span style=3D"white-space: pre-wrap;">=09=09=09supplyingplant,
=
            COALESCE(itm.deliveryitem,''= ) AS DELIVERYITEM,
=09=09<= /span>    min(eventtime) as eventtime 
 FROM = sor_t.transfer_order_header hed,sor_t.transfer_order_item itm 
 where hed.eventid=3Ditm.eventid group by 1,2,3,4,5,6

Query Planner[2]:

= "Finalize GroupAggregate (cost=3D1930380.06..4063262.= 11 rows=3D16004137 width=3D172) (actual time=3D56050.500..83268.566 rows=3D= 15891873 loops=3D1)" " Group Key: (COALESCE(itm.serialnumber, ''::c= haracter varying)), (COALESCE(itm.item_sku, ''::character varying)), (COALE= SCE(itm.receivingplant, ''::character varying)), (COALESCE(itm.sto_id, ''::= character varying)), hed.supplyingplant, (COALESCE(itm.deliveryitem, ''::ch= aracter varying))" " Buffers: shared hit=3D712191 read=3D3, temp = read=3D38232 written=3D38233" " -> Gather Merge (cost=3D1930380.06..366= 9827.09 rows=3D13336780 width=3D172) (actual time=3D56050.488..77106.993 ro= ws=3D15948520 loops=3D1)" " Workers Planned: 2" " Workers Launched: 2" " Buffers: shared hit=3D2213081 read=3D1= 2, temp read=3D142840 written=3D142843" " -> Partial GroupAggregate (cost= =3D1929380.04..2129431.74 rows=3D6668390 width=3D172) (actual time=3D50031.= 458..54888.828 rows=3D5316173 loops=3D3)" " Group Key: (COALESCE(itm.serialn= umber, ''::character varying)), (COALESCE(itm.item_sku, ''::character varyi= ng)), (COALESCE(itm.receivingplant, ''::character varying)), (COALESCE(itm.= sto_id, ''::character varying)), hed.supplyingplant, (COALESCE(itm.delivery= item, ''::character varying))" " Buffers: shared hit=3D2213081 re= ad=3D12, temp read=3D142840 written=3D142843" " -> Sort (cost=3D1929380.04.= .1946051.01 rows=3D6668390 width=3D172) (actual time=3D50031.446..52823.352= rows=3D5332010 loops=3D3)" " Sort Key: (COALESCE(itm.se= rialnumber, ''::character varying)), (COALESCE(itm.item_sku, ''::character = varying)), (COALESCE(itm.receivingplant, ''::character varying)), (COALESCE= (itm.sto_id, ''::character varying)), hed.supplyingplant, (COALESCE(itm.del= iveryitem, ''::character varying))" " Sort Method: external merg= e Disk: 305856kB" " Worker 0: Sort Method: ex= ternal merge Disk: 436816kB" " Worker 1: Sort Method: ex= ternal merge Disk: 400048kB" " Buffers: shared hit=3D2213= 081 read=3D12, temp read=3D142840 written=3D142843" " -> Parallel Hash Join = (cost=3D133229.66..603743.97 rows=3D6668390 width=3D172) (actual time=3D76= 2.925..3901.133 rows=3D5332010 loops=3D3)" " Hash Cond: ((itm.eve= ntid)::text =3D (hed.eventid)::text)" " Buffers: shared hit= =3D2213027 read=3D12" " -> Parallel Seq Scan on transfer_order= _item itm (cost=3D0.00..417722.90 rows=3D6668390 width=3D68) (actua= l time=3D0.005..524.359 rows=3D5332010 loops=3D3)" " Buffers: share= d hit=3D351039" " -> Parallel Hash= (cost=3D118545.68..118545.68 rows=3D1174718 width=3D35) (actual time=3D75= 5.590..755.590 rows=3D926782 loops=3D3)" " Buckets: 41943= 04 Batches: 1 Memory Usage: 243808kB" " Buffers: share= d hit=3D1861964 read=3D12" " -> Paralle= l Index Only Scan using transfer_order_header_eventid_supplyingplant_eventt= ime_idx1 on transfer_order_header hed (cost=3D0.56..118545.68 rows=3D11747= 18 width=3D35) (actual time=3D0.128..388.436 rows=3D926782 loops=3D3)" " Heap Fet= ches: 18322" " Buffers:= shared hit=3D1861964 read=3D12" "Planning Time: 1.068 ms" "Execution Time: 84274.004 ms"

=

Tables[1]&= nbsp; created ddls in dbfiddle.


<= br>
PG Server:&nb= sp; PostgreSQL 11.7 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.9= .3, 64-bit.
RAM: 4= 56
Mem Setti= ngs: 
= "maintenance_work_mem"=09"8563712"=09"kB"
=
"work= _mem"=09 "688552"=09   &nbs= p;    "kB"
"wal_buffers"=09      &nb= sp;            =      "2048"     &n= bsp;        "8kB"
"shared_buffers""8kB"
Any suggestions= would greatly appretiated. 



= Thanks,
Rj


<= /div>

------=_Part_2139400_360393687.1603326749015-- From pryzby@telsasoft.com Thu Oct 22 01:09:07 2020 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 1kVP6W-0007Cl-LB for pgsql-performance@arkaria.postgresql.org; Thu, 22 Oct 2020 01:09:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kVP6V-0001J1-1C for pgsql-performance@arkaria.postgresql.org; Thu, 22 Oct 2020 01:09:19 +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 1kVP6U-0001Iu-Kn for pgsql-performance@lists.postgresql.org; Thu, 22 Oct 2020 01:09:18 +0000 Received: from mail-io1-xd35.google.com ([2607:f8b0:4864:20::d35]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kVP6O-0005NF-4u for pgsql-performance@lists.postgresql.org; Thu, 22 Oct 2020 01:09:17 +0000 Received: by mail-io1-xd35.google.com with SMTP id r9so5188847ioo.7 for ; Wed, 21 Oct 2020 18:09:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=YQivlVOzSkxxeAwfC/BNteLQ0AInBTqtw3aR4cwgD4E=; b=tAzvK3K/fbg1ycZSB533XI1pLx6OBEZcB0/AwbgmWx6Lagkpied6lTCvf7yKpoc94I AIkKOGkaAnaTnr948HhAJDjF/WQRPUea5NI6V8k/yKfyojPsP5lEo3lxfs9dpta2oiF3 9hNHI6iGXYgPViMJOSE8mKCe/oJA1OKHk+Ry/ZPSuF9xI45/fSnh3ahG9wR0zUitqD3Y TGHhGvHkkgj96RCGsuRRJ8ogyxI6g0i8vVPZbj/UDa7K5Y+1EMedfrDGeAhEJmBI4Gn/ gg55/bnoMcQSkjbIX29T6okIvuKY82Q9cQBZAaFRy6na6eFckuaCrjB/zciYRGpX264e +ZpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=YQivlVOzSkxxeAwfC/BNteLQ0AInBTqtw3aR4cwgD4E=; b=fCna973A0vl9ngL445FRDci9rx1bM/swzLCaCGEec/ldPMZPnh0G3QkR2QmWlTchiD 33isEjbWGUWQur6DTZRda3rGXhfdtR0hNFfqFf0IDdkfnAJ4+BzWQJsGTvD1Jv21vy/6 2h3ZZ7IhHkU0cKXj0XR6+im+qbNED8rg5MOthPTizph0/b1iYvLUyL3J2sZ7gOyJpUCK U5wHR+fVLbwUs7jLExltp4oCnNi9H+JzCuJxj6+GuX1y2LG6bLQpiqzDdi61dpvtjxV9 2KWvZ1mR4D5DtlPF8lgenvFDF0d//jEkk9WKpcvhrQ7DSK1j3zgijRmlP4sFfw9xqa5H RSyg== X-Gm-Message-State: AOAM531ta6iyErR/zNqthq7rQ9aGBh0JQoo8eOpgryEnrl5NXk7snBVj mZ8GWH6GdiWIANrUXejtm5z4NRQBmrJSvg== X-Google-Smtp-Source: ABdhPJyW51tHUsvDzCph9AY+ZhnHFDJnTmBbZ04k6YzdHhBEpOzWWfuNYCiIUTku6grBCq/d+ytlyQ== X-Received: by 2002:a6b:ce1a:: with SMTP id p26mr182959iob.94.1603328950841; Wed, 21 Oct 2020 18:09:10 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id m86sm106764ilb.44.2020.10.21.18.09.09 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Oct 2020 18:09:09 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id C2DAE800665; Wed, 21 Oct 2020 20:09:07 -0500 (CDT) Date: Wed, 21 Oct 2020 20:09:07 -0500 From: Justin Pryzby To: Nagaraj Raj Cc: pgsql-performance@lists.postgresql.org Subject: Re: Query performance Message-ID: <20201022010907.GQ9241@telsasoft.com> References: <2026306342.2139401.1603326749019.ref@mail.yahoo.com> <2026306342.2139401.1603326749019@mail.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <2026306342.2139401.1603326749019@mail.yahoo.com> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, Oct 22, 2020 at 12:32:29AM +0000, Nagaraj Raj wrote: > Hi, I have long running query which running for long time and its planner always performing sequnce scan the table2.My gole is to reduce Read IO on the disk cause, this query runns more oftenly ( using this in funtion for ETL).  > > table1: transfer_order_header(records 2782678)table2: transfer_order_item ( records: 15995697)here is the query: > > set work_mem = '688552kB';explain (analyze,buffers)select     COALESCE(itm.serialnumber,'') AS SERIAL_NO,             COALESCE(itm.ITEM_SKU,'') AS SKU,             COALESCE(itm.receivingplant,'') AS RECEIVINGPLANT,  COALESCE(itm.STO_ID,'') AS STO, supplyingplant,            COALESCE(itm.deliveryitem,'') AS DELIVERYITEM,     min(eventtime) as eventtime  FROM sor_t.transfer_order_header hed,sor_t.transfer_order_item itm  where hed.eventid=itm.eventid group by 1,2,3,4,5,6 It spends most its time writing tempfiles for sorting, so it (still) seems to be starved for work_mem. |Sort (cost=1929380.04..1946051.01 rows=6668390 width=172) (actual time=50031.446..52823.352 rows=5332010 loops=3) First, can you get a better plan with 2GB work_mem or with enable_sort=off ? If so, maybe you could make it less expensive by moving all the coalesce() into a subquery, like | SELECT COALESCE(a,''), COALESCE(b,''), .. FROM (SELECT a,b, .. GROUP BY 1,2,..)x; Or, if you have a faster disks available, use them for temp_tablespace. -- Justin From david.g.johnston@gmail.com Thu Oct 22 01:11:15 2020 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 1kVP8l-0007Jb-SE for pgsql-performance@arkaria.postgresql.org; Thu, 22 Oct 2020 01:11:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kVP8k-0007Bl-RV for pgsql-performance@arkaria.postgresql.org; Thu, 22 Oct 2020 01:11:38 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kVP8k-0007Be-Hq for pgsql-performance@lists.postgresql.org; Thu, 22 Oct 2020 01:11:38 +0000 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kVP8i-0003pf-5j for pgsql-performance@lists.postgresql.org; Thu, 22 Oct 2020 01:11:37 +0000 Received: by mail-pj1-x1036.google.com with SMTP id m3so83540pjf.4 for ; Wed, 21 Oct 2020 18:11:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=MwC0aWuoxt1shFisezi0ITT4DfwGWKwxcuo0zd9k4eg=; b=JyJdFQuAh5bnlQeUl7GqXbSkT4HAabFXRDNKVsDzeZADkoy3lkh6cx6SQzwZMxtXqZ WaPHnuDHJyLwhXBRRltHSgCL+yzne0r2waqQiXl2qnoX5NUWFkL015EvZ3nkWWe8E2p9 e86AraHW/ppP/Yu+ulICOv9fQT/VsQ5F5jVMr10CAD1F7rsAKo4F2F2sbVAjrGguvTt+ mI6WFQufjMCle1DiyEuL17Whe+mYynQPFORbpvTk0JyKrQx0ceyA8E187GpQbdZDGeIM oQSo1Cvca/pmj9BbD4PeraNI41S6GOsEb3Wx584oswp234t+MmfbRm9rPKj4jdTbFCqr GXOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=MwC0aWuoxt1shFisezi0ITT4DfwGWKwxcuo0zd9k4eg=; b=irypXxq3r2zit0kHuOr4Hrh7zKyUInccNySQffpYYfFXMM+LC5b9T2Q93sUIMog269 Sp7wwxDodpAZdtRKMasNL/r5qq6jw0MpNK7FHaSfzvOIEiUBKcp7D3EUpYsYDrSL8IxV NXxbfZcHSLIDwrznrkbOF6MZEyCrPOHK1XfRhraUVta/rVUWbcPAYYGU2BdMqz4Z8aQy gGzBcv32xtilgWw0DLxmjJ3Vh+cSvsWFThHLZAKC6kXzUShLfMzqeeCUgY3ft2idd9St HIHaZbrp8aRaENy1XAtZJogQA2vTTgPpQIr7iIiSEpDbLUUxtjqy72t0hb93ZOnUNxLo 2WJQ== X-Gm-Message-State: AOAM530P6EBM+7JU0i7H2jQYJUD8Oeqtkm2pQv2NvBd79Eer+wzhuZQa I9Bv5PhzW61nKyBKvh3W0IP9MA40Ch1nhZUw6oI= X-Google-Smtp-Source: ABdhPJwH//XOObzxmc145DDw/S5MJHsoDjCjlbEe/F9MblH1eA0fbfJ4YuQOPTF3kNVQpwMx4iQv9/BHAnY+ec2eDt8= X-Received: by 2002:a17:90a:3f82:: with SMTP id m2mr91629pjc.222.1603329093665; Wed, 21 Oct 2020 18:11:33 -0700 (PDT) MIME-Version: 1.0 References: <2026306342.2139401.1603326749019.ref@mail.yahoo.com> <2026306342.2139401.1603326749019@mail.yahoo.com> In-Reply-To: <2026306342.2139401.1603326749019@mail.yahoo.com> From: "David G. Johnston" Date: Wed, 21 Oct 2020 18:11:15 -0700 Message-ID: Subject: Re: Query performance To: Nagaraj Raj Cc: Pgsql Performance Content-Type: multipart/alternative; boundary="00000000000016096305b2382541" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --00000000000016096305b2382541 Content-Type: text/plain; charset="UTF-8" On Wed, Oct 21, 2020 at 5:32 PM Nagaraj Raj wrote: > Hi, I have long running query which running for long time and its planner > always performing sequnce scan the table2. > FROM sor_t.transfer_order_header hed,sor_t.transfer_order_item itm > where hed.eventid=itm.eventid group by 1,2,3,4,5,6 > > Any suggestions would greatly appretiated. > You aren't filtering out any rows so it is unsurprising that a sequential scan was chosen to fulfil the request that the entire detail table be consulted. The good news is you have access to parallelism - see if you can increase that factor. Any other suggestions probably requires more knowledge of your problem domain than you've provided here. Finding a way to add a where clause or compute your desired result during record insertion or updating are two other potential avenues of consideration. David J. --00000000000016096305b2382541 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Wed, Oct 21, 2020 at 5:32 PM Nagaraj Raj <nagaraj.sf@yahoo.com> wrote:
Hi, I have long r= unning query which running for long time and its planner always performing = sequnce scan the table2.

=C2=A0FROM sor_t.transfer_order_header hed,sor_t.tra= nsfer_order_item itm=C2=A0
=C2=A0where hed.eventid=3Ditm.eventid = group by 1,2,3,4,5,6

Any suggestions would grea= tly appretiated.=C2=A0

You aren't filtering out any rows so it is unsurprising= that a sequential scan was chosen to fulfil the request that the entire de= tail table be consulted.=C2=A0 The good news is you have access to parallel= ism - see if you can increase that factor.

Any other s= uggestions probably requires more knowledge of your problem domain than you= 've provided here.

Finding a way to add a where=C2= =A0clause or compute your desired result during record insertion or updatin= g are two other potential avenues of consideration.

Da= vid J.

--00000000000016096305b2382541-- From steve.dirschel@thomsonreuters.com Wed Jul 21 17:13:05 2021 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 1m6FmY-0006hK-Ly for pgsql-performance@arkaria.postgresql.org; Wed, 21 Jul 2021 17:13:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m6FmW-0005H4-6U for pgsql-performance@arkaria.postgresql.org; Wed, 21 Jul 2021 17:13:16 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m6FmV-0005Gw-FW for pgsql-performance@lists.postgresql.org; Wed, 21 Jul 2021 17:13:15 +0000 Received: from mail-dm6nam12on2085.outbound.protection.outlook.com ([40.107.243.85] helo=NAM12-DM6-obe.outbound.protection.outlook.com) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m6FmQ-0002zS-Gf for pgsql-performance@lists.postgresql.org; Wed, 21 Jul 2021 17:13:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aORQ3S+G8jAHqBkbIqN7+80ADZml9WezuB04i0NZBUEHirhyfNNnlq4ru/4giWb99UxJLI2/5PgxaH6JaFdXC9WvNL8qPshkYZLqkIOc16GKYUnN3sS1r63TX4o8wfYxoBnEiRP4bSuATrPF5Qft2nsHIej2KhMjvS2sUNFr3dACV9XwQfYehaN5Nrhw91HsVsN+oNxxFrKldPvMCzab7u9C6ZZJ65/VsT/Onf1/Va6dfl6rJuCqopFVwvagi2EEvKiFmoZl6HNc0CVjtstb3tGQ51krQvCQ0j2O1Z2oeHzIN5nKgMjhvvlWROBVWSPUgWKfOgnYl8PA1tEHK6O64g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=W0p8tucWR5Addw2B5bvd3itK1v8UriZjG5xKknh22xk=; b=RrmKVY19V0Vcvw+83tOVk76sdoAFTyTusOODGZiGVqBbS/e14fjYGGy0+zLs/DDF7zTmdFKeMeEu+84dJBAAFYwV8bu4k2mkvHaQScl9GxSQ/GSPkDYEmCZtqBLTPRGuaUZ7zDtWj2r8XeQTTuFbQxV4gGNRntviW9jPsLgTOHczlNvbey2sjJFegAq12ha8VxJXPfRNuCTrdLYQ5Mh4+/VszOpIbKpCdCdcJYrrH1BJC510EYg7XXZFudg9AW4I5uHBq4B9AYhvLVL5jcoK8LXFtM4uQ7PxMx0EzjlRRAi0ofcaaFGga3R7sMpm2b3qwxCyjQE1u50IGjWFeTNSyg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=thomsonreuters.com; dmarc=pass action=none header.from=thomsonreuters.com; dkim=pass header.d=thomsonreuters.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thomsonreuters.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=W0p8tucWR5Addw2B5bvd3itK1v8UriZjG5xKknh22xk=; b=HAbvVL0iqM4QodF0MBebcgxVyrkc1/em0d6dwvuOFq/GvIBEOQLdRaa3WC+XYh0cZh8t3Ht8a1fJh0nYjykmZjY1BspfYPq2IlVxwPk+bIfKqklR6aawXUhV5pTNn+Svt74iUCnR7TPYfgIAwLjVGSFrlzSQHWjlU5QPHtZP1F8= Received: from DM6PR03MB4332.namprd03.prod.outlook.com (2603:10b6:5:101::21) by DM6PR03MB3852.namprd03.prod.outlook.com (2603:10b6:5:51::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.29; Wed, 21 Jul 2021 17:13:05 +0000 Received: from DM6PR03MB4332.namprd03.prod.outlook.com ([fe80::7075:e84b:ba16:e170]) by DM6PR03MB4332.namprd03.prod.outlook.com ([fe80::7075:e84b:ba16:e170%6]) with mapi id 15.20.4308.026; Wed, 21 Jul 2021 17:13:05 +0000 From: "Dirschel, Steve" To: "pgsql-performance@lists.postgresql.org" Subject: Query Performance Thread-Topic: Query Performance Thread-Index: Add+Uor7jtNzRO6fTcWOBXcacclXKg== Date: Wed, 21 Jul 2021 17:13:05 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: authentication-results: lists.postgresql.org; dkim=none (message not signed) header.d=none;lists.postgresql.org; dmarc=none action=none header.from=thomsonreuters.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 9958c85e-43e3-4c1f-180b-08d94c6ace12 x-ms-traffictypediagnostic: DM6PR03MB3852: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Hz/itq7NLBBRZ3eEgeOOipWgqyQzJoh/vBKZUiTAV690q7RUe5oFE+PEDEbjr/tZFJWfMJqWpeevH/2wSL9wkJXQZx8kHvR5sLfPpN4LDQ0g8txJUtU5yBpSkHsNLqqs7Pd2f1hL4nqcTTBm5imhJlfkj7/nndxnVLqflJAJxXYTSPxRRjFGiHQ35DkNRXAcI3G2lkgCuKREdKX3yVMKfLRX9X7a6TBzOxbydoXQ8YMrJ9XsuAO1mx9JUhkwr0zC0PkDhxjj6CAPqScMfXnre9bB05NdpzMhvD8WqxiI/AD4w+0LIs2JYGFRI6xMKjKylv6JiPCKkGORkE93uPCAv9oJNg4QBBQPHdQUg004sb/DZ21UsjSi1SWto+DoQChFJdRZI7VrnORjlNnWnPve730whH7SU9OE5FjapDWkZVDo/d4rOR9BjCdCKBbfnTN/YIXN/cadV49zfdq7XLp9E7mhYb4bWf9cT+J5hl5SOfs3FnGBtgcXKFtIv3cMZCH451WCfPtqgbY4hfHKk9MI0xiLufjbeUxUc2TeROVO0l7boUmOHmD/0X7/PL4zNdMIKvwTRfn3+7vmV3RUEmDsUPYMQgaBVDQiOkrGTyxw9ySwEdWiatNs1nwnHZ7eootNdtmL6Cdajmiy1J5NKhwgMM4ufmYz3OwkgMXR0Or2o5UpLP3YDZ7vHltP8wELTKPC9HfEFvlnGPFkCMIVuumCew== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR03MB4332.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(136003)(396003)(346002)(376002)(39860400002)(9686003)(66476007)(64756008)(66446008)(2906002)(186003)(66556008)(6916009)(5660300002)(122000001)(316002)(38100700002)(8936002)(6506007)(7696005)(86362001)(83380400001)(966005)(71200400001)(478600001)(52536014)(8676002)(3480700007)(99936003)(7116003)(33656002)(55016002)(66576008)(66946007)(76116006)(38070700004);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?YM5seFIEvlzubv+81VPZyINkEWrK6I0jMAuJb1fGmePQvOw8ebtqD3TbWswG?= =?us-ascii?Q?yzKlJCRsHa6B4XOANTu8Y1yq9t9cUwU3Ir+iEjJYCsQjfyEgL05R38XidQsz?= =?us-ascii?Q?ugviKE9/kWJaQa4T5li8sKdn8JIdj60ZwS6VEeZKK84XbfuSyJOd/U4l8mLx?= =?us-ascii?Q?4/E9/hSzlH3Xtlw9+bTjUCpi5rE/Z4RFD0Io9KaRPtW1hddZlMbrUUxWTyrz?= =?us-ascii?Q?sckeEcSfPH/e4eiiGETvBb+uwaT437NBdf6cqGW82bcFbLHJayHAuO0XZr1o?= =?us-ascii?Q?3vFgrbcrZQULTA5Iq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= =?us-ascii?Q?ULHYWHg3sRlomVNi31FkkMoHgQnh6d8sFednpJYCEYma1RvoF14eMUjhhlVT?= =?us-ascii?Q?Ap/lPa6nj3fy19SIIsLaZL6sh//b5uxd0j1y56ldrCSr4QUPIjeOtb+oRCob?= =?us-ascii?Q?kw5lIMXLrS7AYrL+AVoldoeqgNqh2/UT7n7iWxGkBUYmNEVV1dpM02ZEXWh/?= =?us-ascii?Q?TE/KxUYc4vnEz+oweJV3DGHb1oJN?= x-ms-exchange-transport-forked: True Content-Type: multipart/mixed; boundary="_005_DM6PR03MB4332CC5841DDD299A01EF189FAE39DM6PR03MB4332namp_" MIME-Version: 1.0 X-OriginatorOrg: thomsonreuters.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR03MB4332.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9958c85e-43e3-4c1f-180b-08d94c6ace12 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jul 2021 17:13:05.5673 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 62ccb864-6a1a-4b5d-8e1c-397dec1a8258 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: kOAMG4zUvUAiuS9Gsj6MScNhVmtOnh0umOeWxa3tEgqfJR1VOMiF2jAtMRBZ4ck0s/iK5bA5gsuqYqUNbBfZH3dpmBEY5Nx7VB42Da+Az1rHj4Sn8zaujaJWXm7lZymS X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR03MB3852 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --_005_DM6PR03MB4332CC5841DDD299A01EF189FAE39DM6PR03MB4332namp_ Content-Type: multipart/alternative; boundary="_000_DM6PR03MB4332CC5841DDD299A01EF189FAE39DM6PR03MB4332namp_" --_000_DM6PR03MB4332CC5841DDD299A01EF189FAE39DM6PR03MB4332namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable New to Postgres, Oracle background. With Oracle the amount of work a query= does is tracked via logical reads. Oracle tracks logical and physical rea= ds differently than Postgres. With Oracle a physical read is always consid= ered a logical read. So if a query reads 5 blocks are all 5 are read from = disk the query would do 5 logical reads, 5 physical reads. It appears with= Postgres Buffers shared hit are reads from memory and Buffer shared read i= s off disk. To get total reads one would need to add up shared hits + shar= ed reads. I have a sample query that is doing more work if some of the reads are phys= ical reads and I'm trying to understand why. If you look at attached Query= WithPhyReads.txt it shows the query did Buffers: shared hit=3D171 read=3D88= 0. So it did 171 + 880 =3D 1051 total block reads (some logical, some phys= ical). QueryWithNoPhyReads.txt shows execution statistics of the execution= of the exact same query with same data point. The only difference is the = first execution loaded blocks into memory so this execution had all shared = hits. In this case the query did this much work: Buffers: shared hit=3D58= 1. With Oracle that would not happen. If the 2nd execution of the query did a= ll reads from memory the shared hits would be 1051, not 581. So it appears to me that with Postgres when a query does physical reads it = not only has the expense of doing those disk reads but there is also extra = work done to increase overall block reads for a query. But I don't underst= and why that would be the case. Could someone explain why this is happenin= g? Thanks This e-mail is for the sole use of the intended recipient and contains info= rmation that may be privileged and/or confidential. If you are not an inten= ded recipient, please notify the sender by return e-mail and delete this e-= mail and any attachments. Certain required legal entity disclosures can be = accessed on our website: https://www.thomsonreuters.com/en/resources/disclo= sures.html --_000_DM6PR03MB4332CC5841DDD299A01EF189FAE39DM6PR03MB4332namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

New to Postgres, Oracle background.  With Oracl= e the amount of work a query does is tracked via logical reads.  Oracl= e tracks logical and physical reads differently than Postgres.  With O= racle a physical read is always considered a logical read.  So if a query reads 5 blocks are all 5 are read from disk the = query would do 5 logical reads, 5 physical reads.  It appears with Pos= tgres Buffers shared hit are reads from memory and Buffer shared read is of= f disk.  To get total reads one would need to add up shared hits + shared reads.

 

I have a sample query that is doing more work if som= e of the reads are physical reads and I’m trying to understand why.&n= bsp; If you look at attached QueryWithPhyReads.txt it shows the query did B= uffers: shared hit=3D171 read=3D880.  So it did 171 + 880 =3D 1051 total block reads (some logical, some physical).  Quer= yWithNoPhyReads.txt shows execution statistics of the execution of the exac= t same query with same data point.  The only difference is the first e= xecution loaded blocks into memory so this execution had all shared hits.  In this case the query did this much work: = ; Buffers: shared hit=3D581.

 

With Oracle that would not happen.  If the 2nd execution of the query did all reads from memory the shared hits= would be 1051, not 581. 

 

So it appears to me that with Postgres when a query = does physical reads it not only has the expense of doing those disk reads b= ut there is also extra work done to increase overall block reads for a quer= y.  But I don’t understand why that would be the case.  Could someone explain why this is happening?=

 

Thanks

This e-mail is for the sole use of the intended recipient and contains info= rmation that may be privileged and/or confidential. If you are not an inten= ded recipient, please notify the sender by return e-mail and delete this e-= mail and any attachments. Certain required legal entity disclosures can be accessed on our website: https://= www.thomsonreuters.com/en/resources/disclosures.html --_000_DM6PR03MB4332CC5841DDD299A01EF189FAE39DM6PR03MB4332namp_-- --_005_DM6PR03MB4332CC5841DDD299A01EF189FAE39DM6PR03MB4332namp_ Content-Type: text/plain; name="QueryWithNoPhyReads.txt" Content-Description: QueryWithNoPhyReads.txt Content-Disposition: attachment; filename="QueryWithNoPhyReads.txt"; size=23542; creation-date="Wed, 21 Jul 2021 16:31:47 GMT"; modification-date="Wed, 21 Jul 2021 16:31:47 GMT" Content-Transfer-Encoding: base64 IGV4cGxhaW4gKGFuYWx5emUsIHZlcmJvc2UsIGNvc3RzLCBzZXR0aW5ncywgYnVmZmVycywgdGlt aW5nLCBzdW1tYXJ5LCBoYXNoZXMpDQooLyorIEluZGV4U2NhbihoaXN0b3J5ZXZlMF8gaGlzdG9y eV9ldmVudF9pZHgwMikgKi8gc2VsZWN0IGRpc3RpbmN0IGhpc3RvcnlldmUwXy5FVkVOVF9UWVBF IGFzIGp1bmsxMjMNCmZyb20gSElTVE9SWV9FVkVOVCBoaXN0b3J5ZXZlMF8NCndoZXJlIGhpc3Rv cnlld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MiANCiBTZXR0aW5nczogZWZmZWN0aXZlX2NhY2hlX3NpemUgPSAnODgy ODM1MjhrQicsIGVuYWJsZV9iaXRtYXBzY2FuID0gJ29mZicsIHNlYXJjaF9wYXRoID0gJ2hpc3Qy Jw0KIFBsYW5uaW5nIFRpbWU6IDMuNzYyIG1zDQogRXhlY3V0aW9uIFRpbWU6IDExLjg2MyBtcw0K IFNRTCBIYXNoOiA5MDExMTMwOTUsIFBsYW4gSGFzaDogLTE4MTU2MDE3MjENCigxMzMgcm93cykN Cg== --_005_DM6PR03MB4332CC5841DDD299A01EF189FAE39DM6PR03MB4332namp_ Content-Type: text/plain; name="QueryWithPhyReads.txt" Content-Description: QueryWithPhyReads.txt Content-Disposition: attachment; filename="QueryWithPhyReads.txt"; size=24301; creation-date="Wed, 21 Jul 2021 16:31:33 GMT"; modification-date="Wed, 21 Jul 2021 16:31:33 GMT" Content-Transfer-Encoding: base64 IGV4cGxhaW4gKGFuYWx5emUsIHZlcmJvc2UsIGNvc3RzLCBzZXR0aW5ncywgYnVmZmVycywgdGlt aW5nLCBzdW1tYXJ5LCBoYXNoZXMpDQooLyorIEluZGV4U2NhbihoaXN0b3J5ZXZlMF8gaGlzdG9y eV9ldmVudF9pZHgwMikgKi8gc2VsZWN0IGRpc3RpbmN0IGhpc3RvcnlldmUwXy5FVkVOVF9UWVBF IGFzIGp1bmsxMjMNCmZyb20gSElTVE9SWV9FVkVOVCBoaXN0b3J5ZXZlMF8NCndoZXJlIGhpc3Rv cnlldmUwXy5QUklTTV9HVUlEPSdpMGFjYzA1MWMwMDAwMDEzM2Y1N2Y0YmUyYmJiZGM1ZWYnDQph bmQgaGlzdG9yeWV2ZTBfLklTX0RFTEVURUQ9MA0KYW5kIChoaXN0b3J5ZXZlMF8uRVZFTlRfVFlQ RSBub3QgaW4gKCd2ZXJzaW9uc1NlYXJjaFdpdGhpblF1ZXJ5RXZlbnQnLCdub3Rlc09mRGVjaXNp b25zU2VhcmNoV2l0aGluUXVlcnlF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mUwX18yMS5pc19kZWxldGVkID0gJzAnOjpudW1lcmljKSkNCiAgICAgICAgICAgICAgICAg ICAgIEZpbHRlcjogKCgoaGlzdG9yeWV2ZTBfXzIxLmV2ZW50X3R5cGUpOjp0ZXh0IDw+IEFMTCAo J3t2ZXJzaW9uc1NlYXJjaFdpdGhpblF1ZXJ5RXZlbnQsbm90ZXNPZkRlY2lzaW9uc1NlYXJjaFdp dGhpblF1ZXJ5RXZlbnQsY2l0aW5nUmVmZXJlbmNlc1NlYXJjaFdpdGhpblF1ZXJ5RXZlbnQsdG9j U2VhcmNoV2l0aGluUXVlcnlFdmVudCxzZWFyY2hXaXRoaW5Eb2N1bWVudEV2ZW50fSc6OnRleHRb XSkpIEFORCAoKChoaXN0b3J5ZXZlMF9fMjEucHJvZHVjdF92aWV3KTo6dGV4dCA9IEFOWSAoJ3tE ZWZhdWx0UHJvZHVjdFZpZXcsVE5QUGx1cyxQTENVUyxJbmRpZ28sSU5ESUdPQ0F9Jzo6dGV4dFtd KSkgT1IgKGhpc3RvcnlldmUwX18yMS5wcm9kdWN0X3ZpZXcgSVMgTlVMTCkpKQ0KICAgICAgICAg ICAgICAgICAgICAgQnVmZmVyczogc2hhcmVkIGhpdD0yIA0KIFNldHRpbmdzOiBlZmZlY3RpdmVf Y2FjaGVfc2l6ZSA9ICc4ODI4MzUyOGtCJywgZW5hYmxlX2JpdG1hcHNjYW4gPSAnb2ZmJywgc2Vh cmNoX3BhdGggPSAnaGlzdDInDQogUGxhbm5pbmcgVGltZTogMy43NzQgbXMNCiBFeGVjdXRpb24g VGltZTogNjQ3LjA4NiBtcw0KIFNRTCBIYXNoOiA5MDExMTMwOTUsIFBsYW4gSGFzaDogLTE4MTU2 MDE3MjENCigxNDcgcm93cykNCg== --_005_DM6PR03MB4332CC5841DDD299A01EF189FAE39DM6PR03MB4332namp_-- From tgl@sss.pgh.pa.us Wed Jul 21 18:03:35 2021 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 1m6GZK-0000X4-PY for pgsql-performance@arkaria.postgresql.org; Wed, 21 Jul 2021 18:03:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m6GZJ-0004N6-LJ for pgsql-performance@arkaria.postgresql.org; Wed, 21 Jul 2021 18:03:41 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m6GZJ-0004My-Ch for pgsql-performance@lists.postgresql.org; Wed, 21 Jul 2021 18:03:41 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m6GZF-0003OH-UH for pgsql-performance@lists.postgresql.org; Wed, 21 Jul 2021 18:03:41 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 16LI3Z2a713203; Wed, 21 Jul 2021 14:03:36 -0400 From: Tom Lane To: "Dirschel, Steve" cc: "pgsql-performance@lists.postgresql.org" Subject: Re: Query Performance In-reply-to: References: Comments: In-reply-to "Dirschel, Steve" message dated "Wed, 21 Jul 2021 17:13:05 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <713201.1626890615.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 21 Jul 2021 14:03:35 -0400 Message-ID: <713202.1626890615@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "Dirschel, Steve" writes: > I have a sample query that is doing more work if some of the reads are p= hysical reads and I'm trying to understand why. If you look at attached Q= ueryWithPhyReads.txt it shows the query did Buffers: shared hit=3D171 read= =3D880. So it did 171 + 880 =3D 1051 total block reads (some logical, som= e physical). QueryWithNoPhyReads.txt shows execution statistics of the ex= ecution of the exact same query with same data point. The only difference= is the first execution loaded blocks into memory so this execution had al= l shared hits. In this case the query did this much work: Buffers: share= d hit=3D581. You haven't provided a lot of context for this observation, but I can think of at least one explanation for the discrepancy. If the first query was the first access to these tables after a bunch of updates, it would have been visiting a lot of now-dead row versions. It would then have marked the corresponding index entries dead, resulting in the second execution not having to visit as many heap pages. regards, tom lane From kenny.pg18@gmail.com Mon Jul 26 23:59:19 2021 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 1m97ZZ-0000oi-BX for pgsql-performance@arkaria.postgresql.org; Thu, 29 Jul 2021 15:03:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m97ZY-000555-9j for pgsql-performance@arkaria.postgresql.org; Thu, 29 Jul 2021 15:03:44 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m8AVU-0006pg-3a; Mon, 26 Jul 2021 23:59:36 +0000 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1m8AVM-0007H4-OO; Mon, 26 Jul 2021 23:59:35 +0000 Received: by mail-wr1-x42d.google.com with SMTP id z4so1149415wrv.11; Mon, 26 Jul 2021 16:59:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=8mrVVhuLmeB0aqjAe9hzQrYMeiXlDEnYvSvAKpHJ9uU=; b=CyXUUtaZfWsLhper5/lxKOwIQXxUhx1EMpVSRh35esFJVMc3NSn6FBoXyPpRQ8Ekkb pMmYsK6Vx6evWZNl9iQdU/8mtnVLaDl4Hl/kgsYbY59v1RZ0mKTqJ75F9IWYIDgULqBC rjtOVaKw4T/Ha6vgWnbDRJYZAUbPz3ytOCKH7zvmxq24mJvzhB0MUVL5M9qnceqxhV9r /Dh5QZuw3LEm15CP3LM7EA1G3NHSssUJXHLF2kVQGD8EBgvVwsTqAZhHk6pnwgb84WB8 fJz0cInj/du3Eiqa4Cq/PAkjsLRHyA196djwI/JrqXaYZryh+JzckDnBMCQYbrZiA7ii ewfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=8mrVVhuLmeB0aqjAe9hzQrYMeiXlDEnYvSvAKpHJ9uU=; b=FtF1AAE1cy5Dz0AimsEgcagjqoHs0QUogMkNSviqlcH2kt9f1Lej4u3PHA0WBsSu9U QLeFs+5NOCimmcGEzxKhgO3rJKcYJLcGiAN9BcyHwJOc3IzmgCkZUVYOO+VD/8l1rJ3V /Ws8OVsjG2xrQIS9ibT1AwjcsYpBt0XoEEteV9/v9mZqbLns2dtDK0uviCcWKGiYFcKN Q1R2NZQ4BMR6FICZkTRTc5FQwLW8UoN9JKkRcAjwcADXo9zoPyduQdTIbB64Vi+DhPPh KoXiiKizPb18JAwCWv+lbkpN5p03Qs+3ml4tdeeyAaFdVpbU2mV6LGwkfJ5Nkj759/h3 xe6w== X-Gm-Message-State: AOAM531NDErhbC6eEfISATY2x0hWCvxMTRUv4VRmfVwEsBBKcbpALnls hjSI3QZdSlvPb5gou9uQm2OKY7pK2zbiVS85Gdw41WiI/ICG8A== X-Google-Smtp-Source: ABdhPJz3EA5gTid6ZNwtNb4NKwo2Iia2MmSSIm26Koi4TTChLzVHdEs20X0iOAXs+JYMNYcbWhODbw83c59Lz4L8Iho= X-Received: by 2002:a05:6000:1787:: with SMTP id e7mr21566025wrg.209.1627343966751; Mon, 26 Jul 2021 16:59:26 -0700 (PDT) MIME-Version: 1.0 From: kenny a Date: Tue, 27 Jul 2021 05:29:19 +0530 Message-ID: Subject: Query performance ! To: pgsql-sql@lists.postgresql.org, pgsql-performance@lists.postgresql.org, pgsql-general@lists.postgresql.org, pgsql-admin@lists.postgresql.org Content-Type: multipart/mixed; boundary="00000000000010e30b05c80f8b43" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000010e30b05c80f8b43 Content-Type: multipart/alternative; boundary="00000000000010e30705c80f8b41" --00000000000010e30705c80f8b41 Content-Type: text/plain; charset="UTF-8" Hi Experts, The attached query is performing slow, this needs to be optimized to improve the performance. Could you help me with query rewrite (or) on new indexes to be created to improve the performance? Thanks a ton in advance for your support. --00000000000010e30705c80f8b41 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Experts,

The attached que= ry is performing slow, this needs to be optimized to improve the performanc= e.

Could you help me with query rewrite (or) on new= indexes to be created to improve the performance?

= Thanks a ton in advance for your=C2=A0support.=C2=A0
--00000000000010e30705c80f8b41-- --00000000000010e30b05c80f8b43 Content-Type: text/plain; charset="US-ASCII"; name="Query_RExe.txt" Content-Disposition: attachment; filename="Query_RExe.txt" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_krlag29m0 U0VMRUNUIHRhYjIucnVsZW5hbWUsDQogICAgICAgdGFiMi50b3RhbGV4ZWN1dGVkLA0KICAgICAg IHRhYjIudW5pcXVlb3JkZXIsDQogICAgICAgdGFiMS5kZXMgICAgICAgICBkZXNjcmlwdGlvbiwN CiAgICAgICB0YWIyLm1heCwNCiAgICAgICB0YWIxLnJ1bGV0eXBlLA0KICAgICAgIHRhYjIudW5p cXVlb3JkZXIgcGVydGFuZ2UNCkZST00gICAoU0VMRUNUIHJlLnJ1bGVfbmFtZSAgICAgICAgICAg ICAgICAgcnVsZU5hbWUsDQogICAgICAgICAgICAgICBDb3VudCAoKikgICAgICAgICAgICAgICAg ICAgIHRvdGFsRXhlY3V0ZWQsDQogICAgICAgICAgICAgICBDb3VudCAoRElTVElOQ1QgcmUub3Jk ZXJfaWQpIHVuaXF1ZU9yZGVyLA0KICAgICAgICAgICAgICAgTWF4IChyZS5pZCkNCiAgICAgICAg RlJPTSAgIHJ1bGVfZXhlY3V0aW9uIHJlDQogICAgICAgIFdIRVJFICA/ID0gPw0KICAgICAgICAg ICAgICAgQU5EIHJlLnN0YXR1cyA9ID8NCiAgICAgICAgICAgICAgIEFORCByZS4gdHlwZSBJTiAo ID8sID8gKQ0KICAgICAgICAgICAgICAgQU5EIHJlLm9yZGVyX2lkIElOICggPywgPywgPywgPywN CgkJCSAgICoqKioqKioqKioqKioqKioqKioqKioqKioqKioNCgkJCSAgICoqKioqKioqKioqKioq KioqKioqKioqKioqKiogICAgICAgICAgICAgICAgICAgICAgICAgICAgDQogICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICA/LCA/ICkNCiAgICAgICAgR1JPVVAgIEJZIHJlLnJ1bGVf bmFtZSkgdGFiMg0KICAgICAgIElOTkVSIEpPSU4gKFNFTEVDVCByZTIucnVsZV9uYW1lLA0KICAg ICAgICAgICAgICAgICAgICAgICAgICBNYXggKHJlMi5ydWxlX2Rlc2NyaXB0aW9uKSBkZXMsDQog ICAgICAgICAgICAgICAgICAgICAgICAgIE1heCAocmUyLiB0eXBlKSAgICAgICAgICAgIHJ1bGVU eXBlDQogICAgICAgICAgICAgICAgICAgRlJPTSAgIChTRUxFQ1QgcmU0LnJ1bGVfbmFtZSwNCiAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBNYXggKHJlNC5jcmVhdGVkX2RhdGUpDQog ICAgICAgICAgICAgICAgICAgICAgICAgICBGUk9NICAgc2FtcGxlLnJ1bGVfZXhlY3V0aW9uIHJl NA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgV0hFUkUgID8gPSA/DQogICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgQU5EIHJlNC5zdGF0dXMgPSA/DQogICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgQU5EIHJlNC4gdHlwZSBJTiAoID8sID8gKQ0KICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgIEFORCByZTQub3JkZXJfaWQgSU4gKCA/LCA/LCA/LCA/LA0K CQkJCQkJCQkgICoqKioqKioqKioqKioqKioqKioqKioqKioqKioNCgkJCSAgICAgICAgICAgICAg ICAgICAgICAqKioqKioqKioqKioqKioqKioqKioqKioqKioqICAgICAgICAgICAgICAgICAgICAg IA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICA/LCA/ICkNCiAgICAgICAgICAgICAgICAgICAgICAgICAgIEdST1VQICBCWSByZTQucnVsZV9u YW1lKSByZTENCiAgICAgICAgICAgICAgICAgICAgICAgICAgSU5ORVIgSk9JTiBydWxlX2V4ZWN1 dGlvbiByZTINCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBPTiByZTIucnVsZV9u YW1lID0gcmUxLnJ1bGVfbmFtZQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg IEFORCByZTIuY3JlYXRlZF9kYXRlID0gcmUxLiBtYXgNCiAgICAgICAgICAgICAgICAgICBHUk9V UCAgQlkgcmUyLnJ1bGVfbmFtZSkgdGFiMQ0KICAgICAgICAgICAgICAgT04gdGFiMS5ydWxlX25h bWUgPSB0YWIyLnJ1bGVuYW1lDQpPUkRFUiAgQlkgdG90YWxleGVjdXRlZCBERVNDLA0KICAgICAg ICAgIHJ1bGVuYW1lIEFTQw0KTElNSVQgID8gDQoNCg0KY3VycnJlbnQgaW5kZXhlcyBvbiBydWxl X2V4ZWN1dGlvbiB0YWJsZSA6DQoNCnNhbXBsZV9ydWxlX2V4ZWN1dGlvbl91cHBlcl9zYW1wbGVf aWRfaWR4DQpzYW1wbGVfcnVsZV9leGVjdXRpb25fc2FtcGxlX2lkX2lkeA0Kc2FtcGxlX3J1bGVf ZXhlY3V0aW9uX29yZGVyX2lkX2lkeA0KcnVsZV9wa2V5DQpydWxlX2V4ZWN1dGlvbl9taWdyYXRp b25fdW5pcXVl --00000000000010e30b05c80f8b43-- From kenny.pg18@gmail.com Tue Jul 27 17:14:03 2021 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 1m8Qeo-0000ND-6t for pgsql-performance@arkaria.postgresql.org; Tue, 27 Jul 2021 17:14:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m8Qen-0007dg-6i for pgsql-performance@arkaria.postgresql.org; Tue, 27 Jul 2021 17:14:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m8Qem-0007dY-Ss for pgsql-performance@lists.postgresql.org; Tue, 27 Jul 2021 17:14:16 +0000 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1m8Qek-00079d-M8 for pgsql-performance@lists.postgresql.org; Tue, 27 Jul 2021 17:14:16 +0000 Received: by mail-wr1-x42f.google.com with SMTP id l18so8385507wrv.5 for ; Tue, 27 Jul 2021 10:14:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=UUJMs5BGiFZ/r75i2i46g5XM+DfzIXFsRALdZaHkEeY=; b=h7uyI7G7uyiOHMFY37ondCyvBx7HKvvAg/kTd0mrTba5SYi8LDdnO8noN7D/DrqwTB 8HHAg0GKxjo3xnfAfNQ/ooUuK5lwonGDRVFc+pd7+ubuu7i74mWy6oqrCW6xPn9CPhCG 3QCSXW+6XJyIyeoe51h9++aEhdp1uG6RWAs4WJufF03Hl5zWzjf63eb+HpBeeItq4C8M i8PrNNWLkXu1KaCpm3ybDzvYqgbQgFgM5jfJ67R0Wsb90S9AZrHFdQhfGunBFflv4IW/ Vuabnb1WAQMg4o8wS2BBhSkjZAuHcNKH+Y7mDbgHJURtP4VT9Z2Yy6J/R30qcToypvXa trlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=UUJMs5BGiFZ/r75i2i46g5XM+DfzIXFsRALdZaHkEeY=; b=dQ6bxYQQIsbyGbNPlZ0fOPpiqaoNgj5aT8/ogQpzaKhfyKKf7g5D/x/sK0s1KoJP2D T3rQorRw1dTnmbPokKUoU567uF0DUKST9wL94/IcUTi6yOq3eNRt9xWYKpt4yL8KIB+B ntUolgki7klxXFPsdjvmIzqll5voLgSs8xlPexEvnFx03clXJ+E0pmGR3e8BAgjmG1YN euordbUWYgklJagZAGsgLxDruPWGJxEfpvleyx2kr945OBqCXBfKUPZKyjOhLRveNh4n UHB9lBv1Ne9/0+LbG3nwp65D6sepgyorfggyJejhBW5QFEG3ler3TVO4Vb8aYbL8oEnp d9cQ== X-Gm-Message-State: AOAM533DdU+6Nx7aY3MEFDcxw3LgHrp61jw8MoX0SxYWOD4zuyluM616 eB4VO8S0s8G5CKxdcsx9PQ1t9PEgKRU2H8AbqqxXlOuiP9wfFg== X-Google-Smtp-Source: ABdhPJy0O4W/YFBJwL7oSJPAYYL6m0SrkjcbNCT7CNHXJ6JJu63E1DbTMLDSrAFylA1QMpBfuk4K5N1ddEfytrw/rLM= X-Received: by 2002:a5d:4b44:: with SMTP id w4mr24828529wrs.275.1627406052717; Tue, 27 Jul 2021 10:14:12 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: kenny a Date: Tue, 27 Jul 2021 22:44:03 +0530 Message-ID: Subject: Query performance ! To: pgsql-performance@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000ad766105c81dffe0" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000ad766105c81dffe0 Content-Type: text/plain; charset="UTF-8" > > Hi Experts, > > The attached query is performing slow, this needs to be optimized to > improve the performance. > > Could you help me with query rewrite (or) on new indexes to be created to > improve the performance? > > Thanks a ton in advance for your support. > --000000000000ad766105c81dffe0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Experts,

The attached query is performing slow, this needs to be optimized to imp= rove the performance.

Could you help me with query = rewrite (or) on new indexes to be created to improve the performance?
<= br>
Thanks a ton in advance for your=C2=A0support.=C2=A0
--000000000000ad766105c81dffe0-- From bruce@momjian.us Tue Jul 27 17:18:15 2021 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 1m8Qii-0000Vn-6Q for pgsql-performance@arkaria.postgresql.org; Tue, 27 Jul 2021 17:18:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m8Qih-0006rY-6K for pgsql-performance@arkaria.postgresql.org; Tue, 27 Jul 2021 17:18:19 +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 1m8Qig-0006Sh-N8 for pgsql-performance@lists.postgresql.org; Tue, 27 Jul 2021 17:18:18 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m8Qie-0005aq-FD for pgsql-performance@lists.postgresql.org; Tue, 27 Jul 2021 17:18:17 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1m8Qid-0003Ti-Tv; Tue, 27 Jul 2021 13:18:15 -0400 Date: Tue, 27 Jul 2021 13:18:15 -0400 From: Bruce Momjian To: kenny a Cc: pgsql-performance@lists.postgresql.org Subject: Re: Query performance ! Message-ID: <20210727171815.GA19767@momjian.us> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Jul 27, 2021 at 10:44:03PM +0530, kenny a wrote: > Hi Experts, > > The attached query is performing slow, this needs to be optimized to > improve the performance. > > Could you help me with query rewrite (or) on new indexes to be created to > improve the performance? > > Thanks a ton in advance for your support.  Uh, there is no query, and I think you should read this: https://wiki.postgresql.org/wiki/Slow_Query_Questions -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com If only the physical world exists, free will is an illusion. From pryzby@telsasoft.com Thu Jul 29 15:10:24 2021 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 1m97g8-0000zs-CA for pgsql-performance@arkaria.postgresql.org; Thu, 29 Jul 2021 15:10:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m97g7-00024R-Ax for pgsql-performance@arkaria.postgresql.org; Thu, 29 Jul 2021 15:10:31 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m97g6-000244-UG for pgsql-performance@lists.postgresql.org; Thu, 29 Jul 2021 15:10:31 +0000 Received: from mail-io1-xd2f.google.com ([2607:f8b0:4864:20::d2f]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1m97g3-0004hB-Ky for pgsql-performance@lists.postgresql.org; Thu, 29 Jul 2021 15:10:30 +0000 Received: by mail-io1-xd2f.google.com with SMTP id n19so7690099ioz.0 for ; Thu, 29 Jul 2021 08:10:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=/W6cNQ+ioTtLzo0VwXQAJTRhZXDFL2Beu9NT1AHxX88=; b=pv6y/SZ2cYAfjCBcOdDU6nq/7cINDGf1Mi4gbRignHnK/HCuqruTJcFj4/fMRoCfHT XabNuolnCpQjMJqML75mpvQTPCRDZLkiVFFJ+yJQ26+mR9PuSn3XgT6Ayp2VJSUxvmNj /WYUEfVrSBoR/kHMRxjlb69o+AsEDgrDaoRo4BTZulOayhEOCNJCpHlZdTwd8ONAvOUo i57HmD13TcyJvrD45CCjrwh09tuSN9v6B42PmcbRxRy9TFMca3UVxoq4vq4mCbtDcOOL p3ddST6fEcA9gA3pL5mtEbqA96IZcwjbjQZvONq5wbCvbLKFMfspN1Vor1acTq9p8mZf HvfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=/W6cNQ+ioTtLzo0VwXQAJTRhZXDFL2Beu9NT1AHxX88=; b=gkrvwyM0sU5je9NEOFGbPbYHrWNCbRgLfAMTCwvKDrfyhe1Rxs+9OzaicL2QKRPZOB Mmf84e1Rkr0iEE3ciWx1WY+1luMUl7UrI+IP+b4vHchk7RHle/mcpyEyg0qGmIHWqXcw 08xgoRca1qUwAM0djc2PBbbp/GvQoWCryMiRhF0NaBEVBZyxzzcE4omtZODmrJ5D7P4M ivbl8KNwRiqy11R+vYoh2pimJKxQxoG1mkHhVDOGsb/QVYjoyfFsqHtq8vdFt+lV/OdV rpyW7hCCtS64GUDDoaKsIWz6NRN4CZy2EVaDFbDSWMGJzjLH0ZysaOlRvH3PcWcwHPFO ojwQ== X-Gm-Message-State: AOAM533e2swCoAyyMxITYlyYHSihhUW/Kpex82lueF3crduzn0xylv1o ts3rvbS6LIYCeAOuvyXRt2C7Tg== X-Google-Smtp-Source: ABdhPJz3jjCMJrvqpUe+swGKXLEt2chGVbNoFOS8QoIdHoRDeDA26fs8RWrMnCKekY4SOxy6bWNx9Q== X-Received: by 2002:a6b:794b:: with SMTP id j11mr4514821iop.129.1627571425695; Thu, 29 Jul 2021 08:10:25 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id t11sm2058783ilj.63.2021.07.29.08.10.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Jul 2021 08:10:25 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 5FCED800C82; Thu, 29 Jul 2021 10:10:24 -0500 (CDT) Date: Thu, 29 Jul 2021 10:10:24 -0500 From: Justin Pryzby To: kenny a Cc: pgsql-performance@lists.postgresql.org Subject: Re: Query performance ! Message-ID: <20210729151024.GF12533@telsasoft.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Please don't cross post to multiple lists like this. Cc: pgsql-sql@lists.postgresql.org, pgsql-performance@lists.postgresql.org, pgsql-general@lists.postgresql.org, pgsql-admin@lists.postgresql.org If you're hoping for help on the -performance list, see this page and send the "explain analyze" for this query. https://wiki.postgresql.org/wiki/Slow_Query_Questions On Tue, Jul 27, 2021 at 05:29:19AM +0530, kenny a wrote: > Hi Experts, > > The attached query is performing slow, this needs to be optimized to > improve the performance. > > Could you help me with query rewrite (or) on new indexes to be created to > improve the performance? > > Thanks a ton in advance for your support. From Steve.Dirschel@bestbuy.com Mon Apr 27 15:52:06 2026 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wHOG0-0078Jq-2K for pgsql-performance@arkaria.postgresql.org; Mon, 27 Apr 2026 15:52:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wHOFx-00ERSY-2M for pgsql-performance@arkaria.postgresql.org; Mon, 27 Apr 2026 15:52:21 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wHOFw-00ERSG-2c for pgsql-performance@lists.postgresql.org; Mon, 27 Apr 2026 15:52:21 +0000 Received: from mx0b-002a6b01.pphosted.com ([67.231.153.219]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wHOFn-000000033Gk-3tVt for pgsql-performance@lists.postgresql.org; Mon, 27 Apr 2026 15:52:14 +0000 Received: from pps.filterd (m0098284.ppops.net [127.0.0.1]) by mx0b-002a6b01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63RELiTr3578381 for ; Mon, 27 Apr 2026 15:52:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bestbuy.com; h= content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to; s=S1-20230630; bh=Ht7J1szGfOmNl0x1aPge8i nHc1AHQnC/gfhONW8JMck=; b=YKzXIikordKaGcHqXEWHu18E0rEk1rWfiq6rvC MxNUcOyr6CwLguB9P+7/J74iRuaFDqSwtn4oxAr0GIwZ5MGMkbk0aUH7z6JLExpi pwwd0T1dCLy1e1F9xlX6euucZK0rG39ftduz6LTxITE2dFdQ169pmNtHDsf0ml0K uDuHkRG093zpdg/YPTvtic8ig4+MWAQTStVsJol0GGVuEwq93GR3puIDTpzobCLt x85oaoYIHhkdeGNds1t2sp6/+BqmbknxFbFXh9oWOzE+RXG+KQ9+4wtGJOfbxNig BRGgToUQ3FCyH4mdyxbkWg18sE0EBIxv9hzracNvRUyp7xhQ== Received: from sj2pr03cu001.outbound.protection.outlook.com (mail-westusazon11012057.outbound.protection.outlook.com [52.101.43.57]) by mx0b-002a6b01.pphosted.com (PPS) with ESMTPS id 4dt79pacs2-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT) for ; Mon, 27 Apr 2026 15:52:10 +0000 (GMT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Aq4l+z9xDpfBn5aGR8TmmMyq3oXydVkIsq9ZYbhDxrEZv5b165mZ/cfM8FDerUKP+zO1Gj6d1BTC+TENf38wfuMc0f2PyPyp7HJ+hcnj0GlTpTdqFK0KUnCvNdrxV8MtlExK8d1i4Pwsb7o6iUoZ8UrLUfXBz6GPu3g6LaEOcpSPbQiMPhwy+eLWazYWIjwEklepwzkeK8R+e25M9SQ6hZUlBxTijGYAXiPveyfNTzm9uXADmPRJ5VLxEGROreH86vmOP/NpObX0gLRhXHFKiBn+8eAXZcq7T0AqYztNkk8MCUHGsLKcqnucDeOr7f7bwMyMFSFdXkF8Wns7ziGfIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Ht7J1szGfOmNl0x1aPge8inHc1AHQnC/gfhONW8JMck=; b=JB76BfZ/Fd11EJ9GZzwsmYmhxTR4Arb9xrtfhga85s0ceXmf4gte9+xRm4XcrFOEE394Se9S3veFFAV54CYccialo+TDpjbTxKMK1sbt/0Yr/Rv5vsvDOPr4+hzK7TrAK7DDCMTuv8bkK1tcF1rrAUBG4BmujUInpr9KtPpkpJ+QxbOLNldUQ/OXsZxB0I9BpqcC/3Rd6TXd8HeX1hIil4WCrVbqMx7G2hu2JosHWqjvX9oMXoiyF3G3/WG3CHRrI4f8WQG9uZsHSn/1eK3nccdZCJPrAYZiBEV+2+x2HVZxPeooYEkjh5pTxFUUWkEVjuo2U+LMJysMCGmywpAU3w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=bestbuy.com; dmarc=pass action=none header.from=bestbuy.com; dkim=pass header.d=bestbuy.com; arc=none Received: from BYAPR06MB4471.namprd06.prod.outlook.com (2603:10b6:a03:4b::28) by BY3PR06MB8083.namprd06.prod.outlook.com (2603:10b6:a03:3c6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9846.26; Mon, 27 Apr 2026 15:52:07 +0000 Received: from BYAPR06MB4471.namprd06.prod.outlook.com ([fe80::3079:706e:ea70:a376]) by BYAPR06MB4471.namprd06.prod.outlook.com ([fe80::3079:706e:ea70:a376%3]) with mapi id 15.20.9846.025; Mon, 27 Apr 2026 15:52:06 +0000 From: "Dirschel, Steve-CW" To: "pgsql-performance@lists.postgresql.org" Subject: Query performance Thread-Topic: Query performance Thread-Index: AQHc1l3MHW2pFas4mkKlIQ04Jl3BUQ== Date: Mon, 27 Apr 2026 15:52:06 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_e9c55f1f-f169-4db7-a264-a5084ccbb748_Enabled=True;MSIP_Label_e9c55f1f-f169-4db7-a264-a5084ccbb748_SiteId=135e8995-7d3b-4466-844b-a0d62ba5f495;MSIP_Label_e9c55f1f-f169-4db7-a264-a5084ccbb748_SetDate=2026-04-27T15:35:51.6654596Z;MSIP_Label_e9c55f1f-f169-4db7-a264-a5084ccbb748_Name=Confidential;MSIP_Label_e9c55f1f-f169-4db7-a264-a5084ccbb748_ContentBits=0;MSIP_Label_e9c55f1f-f169-4db7-a264-a5084ccbb748_Method=Standard x-ms-reactions: allow x-ms-publictraffictype: Email x-ms-traffictypediagnostic: BYAPR06MB4471:EE_|BY3PR06MB8083:EE_ x-ms-office365-filtering-correlation-id: c0687424-25f9-4518-e020-08dea474ef23 x-proofpoint-outbound: 2ABD5B1121654D948E7788CED1FE3D92 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|376014|366016|1800799024|38070700021|8096899003|22082099003|18002099003|56012099003; x-microsoft-antispam-message-info: cQv0SLtdqN7EwFXP1PHXND+gx1gzLdWzIbDe8OwJsnFhxgewBEsPysOper0SnENSss2SdHJykjZcGvZlRNmOzSdvYnQxfnG+MlYt7LSi2ceP6x/73/M/naqZqc+j0TQN+IA+7MbiBfuPjkWpNghdkXQh7vGVrrsxAldqAWezcK5qJlp+HvSymzeius+qOZp612fCPwbRpZywyqBIgYD/vNl3SfK88mD37Tn8Y3NVmNy4K1YJZoVlXl34bzG9fcIJZectr8I7SKBp6s0fxFgSa2lzwTYAzJxvOiU+Q76loBVFG4vV4erGVYIQOPa0CFhxCEzPfDwy1TpL+RLA62glAi+pIshsFimJwhOGAIgH0boDS2EtYRLkuUso1jvpMBMlmoubJPQQ0tT5e4jHqZnURtUWzr1YMPdpU+K0vg3fpYqqoRz1j+IAzt8znTEAJCMncKEgTym4JyFnrLakNCFq1Sk5Yt0VnTnH+C8iG3bL0HRDCQ/emyAH/O2qeX/NO4tS0cMi944PaCNkJIdthJ0F7FmEf1JeNW/7+2NC99Te+Ck/tvYBWXeRkTGIzY2Cpgu3D+IGOd4QVu/J8KoxV7QBKcBFmEiJ+ZAteoYJDLF4HXoIfDnnLJ8ctX0cyVRu2W3QMdgQtUfWnA5g34RhNZHAUMNQTtGgPpTW+AyapwMcuqnTEt4/3KVSISgDKj+0Y/IDzJ6qdSSHNeIcOHZpXNIXnBsNzJwvsqb1ETUZGWhS1MrSIrNCsy2DGYvF1WFCLA29oacBRdNhL4fLEQXxNp4+9ni32DDy3abl/zyzJt33Mxg= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR06MB4471.namprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(366016)(1800799024)(38070700021)(8096899003)(22082099003)(18002099003)(56012099003);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?Windows-1252?Q?6JuneBWy3OcWLAWSbD6eenuZmWBJqZ2oKzTiMqaXETV98pGOOrVRkzKL?= =?Windows-1252?Q?CBko6fV3XDnZlsKenuw+6vl5K3bHmGbgYx7LlSUes2PcZmQP5YSRDDx2?= =?Windows-1252?Q?OOzUHIinGn52XRWG3oYhuQ5vXnn6ytnVTOrw/wpRpOz+VB2NqPiQEvna?= =?Windows-1252?Q?zO4GDeqmuFbR/w30w/Ua127KbQ1uLcorRbdphO8jR14CIkb3CxmElOyr?= =?Windows-1252?Q?buSbWTclpNk8zgCcf16Jz/Mdd41xPKnqYFpICnHKkH/s+T2GxTRP5ZCa?= =?Windows-1252?Q?vOGlla9B624tKWx2mLpq4Q8YxTll9MXR5Zm5PivzRrtqeUDU9qHVX46W?= =?Windows-1252?Q?niXAAoZo9bwJe/0Oa2Xs9G2AvfUu/oJ5Y4CP0LQF2lPB3CCAcXv+Bd9w?= =?Windows-1252?Q?75Tjf965tzOUFBsICOGmq0NdgOkcLKaS/toDXCj1yier2gqzr0BsmnGP?= =?Windows-1252?Q?7W39rCheWbmgIaBv38uGTeIryQuBltx6DnxhPhgZoE7ODrV2Py5Aqc09?= =?Windows-1252?Q?q0B5Deo9mWB6HXXqBdUX5PT+SKa82B+jhrzNpU0kM9Wx050xkUHa8pTb?= =?Windows-1252?Q?5z4L5KU+YR7OK1CkCj8O7d8YDf5DvDDJCGZR+boCO6nYwnd39v4vlGeu?= =?Windows-1252?Q?p9rz/+RrtaDL/wAWF5/VBf3dKLmulTuzyl6a/wviPD0MSitTZfgq82O+?= =?Windows-1252?Q?ioqDicnx9cdC/cQbrjU4Ty8FswRVxruQcj33Txrd0PLi8SDPxchoKeQT?= =?Windows-1252?Q?NK+MMEMi3SV7rbGMsXlXITmURhH3rDXKDjciSqNzv8SBa9usuo2el40a?= =?Windows-1252?Q?L9n0cYi9UIS+uY0RUwyYCo+Jpw5o6s/A8GqjccNm+W7y5G5Q/wEHCKMR?= =?Windows-1252?Q?U5pCKYz0+bRxKEIwg6MoBLvM06ioyGhiSi3ETJc/7XouAd/lfTXboHyG?= =?Windows-1252?Q?VHcrk/S0JNB1a3qfX8KBYgKp8c/JJonQ1fbGc4Ce97JgDesuDiaKfdci?= =?Windows-1252?Q?k2n1KAfpR1O63C+zTlGBQL51C05fcloa5t32epBx+CCr0/wGSOcrOQoq?= =?Windows-1252?Q?MqawuXVUjitxPS9UhsYvPPVFJseR3VyUpBb8dvZJRqQ+IbALG/1q5Q9p?= =?Windows-1252?Q?KGa5V4uAaEtPH8rDtqRoqifyK5CyhWcrkhoasg4Ivvc5x/2n/+uZ9ysv?= =?Windows-1252?Q?HJDmztezzPedRtAw7GRf4Htv+jyi+OUG0LB3ZEL150TlC7ItxPhQPdMx?= =?Windows-1252?Q?XjXuwhQYPn6ZHsQoByqyuuAyAaDNCYdyVJKM19IYDt9+mehyVTlC9DdM?= =?Windows-1252?Q?/TKHfypVvAsOdFcwsV8y+ggvuFceH6N/5ozM5CZzgOmUvIpt7t/Bj3MK?= =?Windows-1252?Q?QA1yi4eFYPMUT5K3gsHyIy9piqIKDF9DLM7C9nC/zxvhSraI+SrlkUoe?= =?Windows-1252?Q?hFW6MQj2qKq/QeL1dWinDMwVw4wEUEkLhOYNIw5STbdrPVO16RXXxOJ5?= =?Windows-1252?Q?3rHCoizCJ1zpIU6P7JKm0Z4+tpsTcUtHwfxyfmfp3/mzisag10mzi9kL?= =?Windows-1252?Q?bUI1KsMmiveOMGHhuwqJAHaypIgHLhiQhBBCMtKeSpB28DLMp3bI4P0b?= =?Windows-1252?Q?sREhwu+wMvACvfnAd7//wGElfTMZ9kv3aUIfo29I9bK1Hcf7kn3hutBl?= =?Windows-1252?Q?woAzmCbmpTxlLSb9VIDl9l6r1YTDO/B/qGSkVFEjSpWnF4NYhfcxi/M+?= =?Windows-1252?Q?2nSF5rotzoytzRs0sNpK0K0CjfNB64Vhlp13Da38fwzGEl+k1Dmos83H?= =?Windows-1252?Q?3KP4rUx88Z9HPiDo4oDQ7HoFRSLIW3XEDgKGRLFRglA2KHznh7kuO+2l?= =?Windows-1252?Q?bjF4Z5lRa8tC+cpYTmufygHDztEVYBUnH9w=3D?= Content-Type: multipart/alternative; boundary="_000_BYAPR06MB447199DE1FCF363EF389EF1A8A362BYAPR06MB4471namp_" MIME-Version: 1.0 X-Exchange-RoutingPolicyChecked: NkAV81EF/CwaBBjkxKYloS6ZOo0qU/uM4qS9tsiLcSJg5VtNO3vNLZHOE9SUjTykuhs1ct7zWmqd9TEEiz+ye+MHVYsEngRwT6X45bySCqaoGuiYCwTyzW7IyNwxa+vjqdK6QmaNGBHEwn1i9M6djLl7i9uoaUmPkD2az/vdrjptWONN4tKQYGrr/20UeuZRxInLjtTAO9YebqFMW40WetWtT7fj1EHC3k5h7DmW75EoCeYufpgsuigLPbCxrEivygROtixxS8q7dzv2xPO5uNcGUDoBVnl+4yTivFmBxO4HxB+dRxbSd9js/z6lMxntR4Te72VKAUFXFWljomBtxw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: dlM1smqJutnCKo4dpU1PcCA+bXyMzltyQ0AY/CaclwcaQj9ULPS9f3mJofO7Nos4aBytnYnDHajZR/qKJM+Kn8qxuhvYrqsjfMgJv7YHv1OCkLa2gMWJlOIXopLMm7Ux0fdUOpnvbLh0g80HTXU+1DuDhxZYIpj8oqkabWsH7V8aaMiBCObDrzzM4t1khn0y+CkAmVj9jpxDoz0LHZzd50jUJ7pOGQ9hTH73vkvzwH5U4UJVWIJeGfAoP6JuWWFiVr3yCQ+0g+spD+lVZhlF23QsuPUxvA+L6nhgh8+9+satglRLO8CL8Zi7+4rA1/HS7xt6aZ0jzc9F+reuvqSu7fXRouanBHhNjrhcprEuU/XSvJUSIP24J4tHlZCNK1NgfOGZuxKivFfj6gUOdzQO+xMysie6IUerg/p3xeadHKoXt8Jfy4+MWvnszlPD6svRtnSnVaJmpCMJ7o3bq4Eb3HX6PMZg3ax0fqWapXVM/RJeyiO/n1GmSyJMSXPUw8UlKhTHIHCjhmswwX6DlrhGzqs9dB9NkyyxpIqvLuY32TwIXQHh4oUrlxz9fQkIuu9gF94qmZCeM7hPbN42hiIWgyqwMWxhbrhwLtNW40vpH2UJoMC7h6HkeZB/IWRLOPMZ X-OriginatorOrg: BestBuy.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BYAPR06MB4471.namprd06.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: c0687424-25f9-4518-e020-08dea474ef23 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Apr 2026 15:52:06.7869 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 135e8995-7d3b-4466-844b-a0d62ba5f495 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: BM3wXEyydshPOZT72K5UdEsQwLqMWrGzJW/VDEV7lkNjz2IOmq+c9Mf+a/R5fRdCRL6fqbyeJbLvJxf1dHqlcg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY3PR06MB8083 X-MS-Exchange-CrossPremises-AuthAs: Internal X-MS-Exchange-CrossPremises-AuthMechanism: 04 X-MS-Exchange-CrossPremises-AuthSource: BYAPR06MB4471.namprd06.prod.outlook.com X-MS-Exchange-CrossPremises-TransportTrafficType: Email X-MS-Exchange-CrossPremises-SCL: 1 X-MS-Exchange-CrossPremises-messagesource: StoreDriver X-MS-Exchange-CrossPremises-BCC: X-MS-Exchange-CrossPremises-originalclientipaddress: 168.94.238.45 X-MS-Exchange-CrossPremises-transporttraffictype: Email X-MS-Exchange-CrossPremises-antispam-scancontext: DIR:Originating;SFV:NSPM;SKIP:0; X-MS-Exchange-CrossPremises-processed-by-journaling: Journal Agent X-OrganizationHeadersPreserved: BY3PR06MB8083.namprd06.prod.outlook.com X-Authority-Analysis: v=2.4 cv=NcHWEWD4 c=1 sm=1 tr=0 ts=69ef862a cx=c_pps a=Y/Y9x3HtMOqQL+YbCjVQEg==:117 a=z/mQ4Ysz8XfWz/Q5cLBRGdckG28=:19 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=xqWC_Br6kY4A:10 a=A5OVakUREuEA:10 a=YABJ2S72nEIA:10 a=VkNPw1HP01LnGYTKEx00:22 a=KeFp_MbVbeh7RJJDCzxV:22 a=xazT8dg1DAXQX9sMwihd:22 a=MsrqofZMeygxttoYJc4A:9 a=pILNOxqGKmIA:10 a=I3vv0rsJFCldhy7fNXEA:9 a=ZrNzIkPog90Pk65T:21 a=_W_S_7VecoQA:10 X-Proofpoint-ORIG-GUID: VXJ-WmV_-hScsejE8qY7S9OFZVheJGZb X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDI3MDE2OSBTYWx0ZWRfXzvjgkPqr1W/r 5J0IPIN1R4IMZ0n+uvl5LAKVGTKjGgMPp5ms2ayvLf3MPTUSSIIUMnKZvBe/v0EiqE+5bFFgx7E O/wDE73SAaiqRaL1JS7APOD61nf7P7hAg67byfa+d7L7Lp3NT2tjM/6YBV3HJcmFujORUDHqFsc 4MjtySxi2yTqJ/VWx7jk1TNvyx/l7uf2YdaBjDb8dtANhnxRJIRCx3igtUHa8PgAbdOYDwQy9Pu Qf2eembcVmQYDel1IGzSvpt1cOHovp5r63AcfQ9NwGpNgikmlSUxsqKyVVgrWcuDmTqVP9lXNi6 vgyP8KBL9c5afKNevcFrb78cS9LIaiQkMd8gs4ySZvxqTPTekjW7/b+Hv7Ie9zpUmOMq8rYyR25 Yva0KIJLwjNA1ZSB5j1kA2WBN9z2x43zVpUAwOBpQqoIuVLU4HZ5jWMjNCtdlUK3VBlKIItrsUb vFMxZY3PSz0sbQE3fYA== X-Proofpoint-GUID: VXJ-WmV_-hScsejE8qY7S9OFZVheJGZb X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-27_04,2026-04-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 phishscore=0 spamscore=0 clxscore=1011 bulkscore=0 adultscore=0 impostorscore=0 suspectscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604270169 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --_000_BYAPR06MB447199DE1FCF363EF389EF1A8A362BYAPR06MB4471namp_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Aurora Postgres version 17.4. Table in question: \d poslog_publisher_rms_stage Table "public.poslog_publisher_rms_stage" Column | Type | Collation | Nullable | Defa= ult -------------------+--------------------------+-----------+----------+-----= ---- stage_id | uuid | | not null | status | character varying(100) | | | message_body | text | | not null | error_code | character varying(100) | | | error_category | character varying(100) | | | error_message | text | | | error_retry_count | integer | | | 0 create_date | timestamp with time zone | | not null | now(= ) modified_date | timestamp with time zone | | not null | now(= ) Indexes: "poslog_publisher_rms_stage_pkey" PRIMARY KEY, btree (stage_id) "idx_poslog_publisher_stage_create_date_col" btree (create_date) "idx_poslog_publisher_stage_status_error_retry_count_modi_date_c" btree= (status, error_retry_count, modified_date) Referenced by: TABLE "poslog_publisher_rms_detail" CONSTRAINT "fk_poslog_publisher_det= ail_stage_id" FOREIGN KEY (stage_id) REFERENCES poslog_publisher_rms_stage(= stage_id) Publications: =93sashpsrms_publication" The table is constantly getting loaded into. Rows are inserted with a stat= us ready and then there is a different process looking for that status and = will update to processed after processing the row. We have multiple tables= like this. Then every 2 hours a different process runs this query looking for failed o= r unprocessed rows: select ppse.stage_id as stageId, ppse.status as status, ppse.message_body as messageBody from poslog_publisher_rms_stage ppse where ppse.status in ('UNPROCESSED','FAILED') and ppse.error_retry_count < 3 order by ppse.create_date limit 100; If I run that query with explain it is doing a ton of work to find 0 rows. = The index it uses seems appropriate for the query. = QUERY PLAN ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ------------------------------------------------------------------- Limit (cost=3D10.92..10.93 rows=3D1 width=3D1019) (actual time=3D66566.82= 3..66566.824 rows=3D0 loops=3D1) Buffers: shared hit=3D1509768 read=3D2011479 I/O Timings: shared read=3D79792.017 -> Sort (cost=3D10.92..10.93 rows=3D1 width=3D1019) (actual time=3D665= 66.821..66566.821 rows=3D0 loops=3D1) Sort Key: create_date Sort Method: quicksort Memory: 25kB Buffers: shared hit=3D1509768 read=3D2011479 I/O Timings: shared read=3D79792.017 -> Index Scan using idx_poslog_publisher_stage_status_error_retry= _count_modi_date_c on poslog_publisher_rms_stage ppse (cost=3D0.57..10.91 = rows=3D1 width=3D1019) (actual time=3D66566.761..66566.761 rows=3D0 loops= =3D1) Index Cond: (((status)::text =3D ANY ('{UNPROCESSED,FAILED}'= ::text[])) AND (error_retry_count < 3)) Buffers: shared hit=3D1509765 read=3D2011479 I/O Timings: shared read=3D79792.017 Planning: Buffers: shared hit=3D195 read=3D1 I/O Timings: shared read=3D1.038 Planning Time: 2.909 ms Execution Time: 66581.498 ms The query did 3.5 million block reads when scanning the index of which 1.5 = million were in memory and 2 million were from disk. 5 seconds later I ran= the exact same query again: = QUERY PLAN ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ------------------------------------------------------------- Limit (cost=3D10.92..10.93 rows=3D1 width=3D1019) (actual time=3D23.589..= 23.591 rows=3D0 loops=3D1) Buffers: shared hit=3D18736 -> Sort (cost=3D10.92..10.93 rows=3D1 width=3D1019) (actual time=3D23.= 588..23.589 rows=3D0 loops=3D1) Sort Key: create_date Sort Method: quicksort Memory: 25kB Buffers: shared hit=3D18736 -> Index Scan using idx_poslog_publisher_stage_status_error_retry= _count_modi_date_c on poslog_publisher_rms_stage ppse (cost=3D0.57..10.91 = rows=3D1 width=3D1019) (actual time=3D23.583..23.584 rows=3D0 loops=3D1) Index Cond: (((status)::text =3D ANY ('{UNPROCESSED,FAILED}'= ::text[])) AND (error_retry_count < 3)) Buffers: shared hit=3D18736 Planning Time: 0.118 ms Execution Time: 23.628 ms Now it only did 18k block reads all in memory. It used the same index, it = also returned 0 rows. Between those 2 runs I looked at pg_stat_user_tables= and could see the n_tup_ins increased by 13, n_tup_del increased by 13, n_= live_tup increased by 13, and n_dead_tup increased by 13. n_live_tup was 9= 6 million and n_dead_tup was 8.4 million. 18k logical reads to find 0 rows= is still high but I believe that is most likely caused by the 8.4 million = n_dead_tups. 15 minutes later I ran the query again: = QUERY PLAN ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ------------------------------------------------------------------- Limit (cost=3D10.92..10.93 rows=3D1 width=3D1019) (actual time=3D59431.79= 5..59431.796 rows=3D0 loops=3D1) Buffers: shared hit=3D1286676 read=3D1734000 I/O Timings: shared read=3D70153.578 -> Sort (cost=3D10.92..10.93 rows=3D1 width=3D1019) (actual time=3D594= 31.794..59431.794 rows=3D0 loops=3D1) Sort Key: create_date Sort Method: quicksort Memory: 25kB Buffers: shared hit=3D1286676 read=3D1734000 I/O Timings: shared read=3D70153.578 -> Index Scan using idx_poslog_publisher_stage_status_error_retry= _count_modi_date_c on poslog_publisher_rms_stage ppse (cost=3D0.57..10.91 = rows=3D1 width=3D1019) (actual time=3D59431.789..59431.790 rows=3D0 loops= =3D1) Index Cond: (((status)::text =3D ANY ('{UNPROCESSED,FAILED}'= ::text[])) AND (error_retry_count < 3)) Buffers: shared hit=3D1286676 read=3D1734000 I/O Timings: shared read=3D70153.578 Planning Time: 0.114 ms Execution Time: 59431.839 ms Total blocks reads increased from 18k to 3 million. n_tup_ins, n_tup_del, = n_live_tup, and n_dead_tup all increased by 10,320 over that 15 minute peri= od of time. What is going on here where this query has to do 3+ million block reads to = find 0 rows? And how is it possible when I run the query 2 times in a row = the logical reads from the 2nd run comes down significantly? Is this someh= ow related to determining if rows are visible or something like that? When= I waited 15 minutes between runs the inserted/updated rows only increased = by 10.3k yet total block reads increased by 3 million. Thanks --_000_BYAPR06MB447199DE1FCF363EF389EF1A8A362BYAPR06MB4471namp_ Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable
Aurora Postgres version 17.4.

Table in question:

\d poslog_publisher_rms_stage
                   Table = "public.poslog_publisher_rms_stage"
      Column       |       &nb= sp;   Type           | Collation | Nullable |= Default
-------------------+--------------------------+-----------+----------+-----= ----
 stage_id          | uuid      = ;               |       &= nbsp;   | not null |
 status            | character varying(1= 00)   |           |       &nbs= p;  |
 message_body      | text         &= nbsp;           |         &nbs= p; | not null |
 error_code        | character varying(100)  = |           |          |=
 error_category    | character varying(100)   |   =         |          |
 error_message     | text          =           |           | =          |
 error_retry_count | integer            =      |           |     &= nbsp;    | 0
 create_date       | timestamp with time zone |   =         | not null | now()
 modified_date     | timestamp with time zone |    = ;       | not null | now()
Indexes:
    "poslog_publisher_rms_stage_pkey" PRIMARY KEY, btre= e (stage_id)
    "idx_poslog_publisher_stage_create_date_col" btree = (create_date)
    "idx_poslog_publisher_stage_status_error_retry_count_mod= i_date_c" btree (status, error_retry_count, modified_date)
Referenced by:
    TABLE "poslog_publisher_rms_detail" CONSTRAINT &quo= t;fk_poslog_publisher_detail_stage_id" FOREIGN KEY (stage_id) REFERENC= ES poslog_publisher_rms_stage(stage_id)
Publications:
    =93sashpsrms_publication"

The table is constantly getting loaded into.  Rows are inserted with a= status ready and then there is a different process looking for that status= and will update to processed after processing the row.  We have multi= ple tables like this.

Then every 2 hours a different process runs this query looking for failed o= r unprocessed rows:

select
                     = ; ppse.stage_id as stageId,
                     = ; ppse.status as status,
                     = ; ppse.message_body as messageBody
                    from<= /div>
                     = ; poslog_publisher_rms_stage ppse
                    where=
                     = ; ppse.status in ('UNPROCESSED','FAILED')
                     = ; and ppse.error_retry_count < 3
                    order= by
                     = ; ppse.create_date
                    limit= 100;

If I run that query with explain it is doing a ton of work to find 0 rows. =  The index it uses seems appropriate for the query.

 &nbs= p;                    &nb= sp;                     &= nbsp;                    =                     &nbs= p;                QUERY PLAN=
---------------------------------------------------------------------------= ---------------------------------------------------------------------------= -------------------------------------------------------------------
 Limit  (cost=3D10.92..10.93 rows=3D1 width=3D1019) (actual time= =3D66566.823..66566.824 rows=3D0 loops=3D1)
   Buffers: shared hit=3D1509768 read=3D2011479
   I/O Timings: shared read=3D79792.017
   ->  Sort  (cost=3D10.92..10.93 rows=3D1 width=3D1= 019) (actual time=3D66566.821..66566.821 rows=3D0 loops=3D1)
         Sort Key: create_date
         Sort Method: quicksort  Memory: 25kB=
         Buffers: shared hit=3D1509768 read=3D2011= 479
         I/O Timings: shared read=3D79792.017
         ->  Index Scan using idx_poslog_p= ublisher_stage_status_error_retry_count_modi_date_c on poslog_publisher_rms= _stage ppse  (cost=3D0.57..10.91 rows=3D1 width=3D1019) (actual time= =3D66566.761..66566.761 rows=3D0 loops=3D1)
               Index Cond: (((statu= s)::text =3D ANY ('{UNPROCESSED,FAILED}'::text[])) AND (error_retry_count &= lt; 3))
               Buffers: shared hit= =3D1509765 read=3D2011479
               I/O Timings: shared = read=3D79792.017
 Planning:
   Buffers: shared hit=3D195 read=3D1
   I/O Timings: shared read=3D1.038
 Planning Time: 2.909 ms
 Execution Time: 66581.498 ms

The query did 3.5 million block reads when scanning the index of which 1.5 = million were in memory and 2 million were from disk.  5 seconds later = I ran the exact same query again:

                     = ;                     &nb= sp;                     &= nbsp;                    =               QUERY PLAN
---------------------------------------------------------------------------= ---------------------------------------------------------------------------= -------------------------------------------------------------
 Limit  (cost=3D10.92..10.93 rows=3D1 width=3D1019) (actual time= =3D23.589..23.591 rows=3D0 loops=3D1)
   Buffers: shared hit=3D18736
   ->  Sort  (cost=3D10.92..10.93 rows=3D1 width=3D1= 019) (actual time=3D23.588..23.589 rows=3D0 loops=3D1)
         Sort Key: create_date
         Sort Method: quicksort  Memory: 25kB=
         Buffers: shared hit=3D18736
         ->  Index Scan using idx_poslog_p= ublisher_stage_status_error_retry_count_modi_date_c on poslog_publisher_rms= _stage ppse  (cost=3D0.57..10.91 rows=3D1 width=3D1019) (actual time= =3D23.583..23.584 rows=3D0 loops=3D1)
               Index Cond: (((statu= s)::text =3D ANY ('{UNPROCESSED,FAILED}'::text[])) AND (error_retry_count &= lt; 3))
               Buffers: shared hit= =3D18736
 Planning Time: 0.118 ms
 Execution Time: 23.628 ms

Now it only did 18k block reads all in memory.  It used the same index= , it also returned 0 rows.  Between those 2 runs I looked at pg_stat_u= ser_tables and could see the n_tup_ins increased by 13, n_tup_del increased= by 13, n_live_tup increased by 13, and n_dead_tup increased by 13.  n_live_tup was 96 million and n_dead_tup was 8.4 mi= llion.  18k logical reads to find 0 rows is still high but I believe t= hat is most likely caused by the 8.4 million n_dead_tups.

15 minutes later I ran the query again:

 &nbs= p;                    &nb= sp;                     &= nbsp;                    =                     &nbs= p;                QUERY PLAN=
---------------------------------------------------------------------------= ---------------------------------------------------------------------------= -------------------------------------------------------------------
 Limit  (cost=3D10.92..10.93 rows=3D1 width=3D1019) (actual time= =3D59431.795..59431.796 rows=3D0 loops=3D1)
   Buffers: shared hit=3D1286676 read=3D1734000
   I/O Timings: shared read=3D70153.578
   ->  Sort  (cost=3D10.92..10.93 rows=3D1 width=3D1= 019) (actual time=3D59431.794..59431.794 rows=3D0 loops=3D1)
         Sort Key: create_date
         Sort Method: quicksort  Memory: 25kB=
         Buffers: shared hit=3D1286676 read=3D1734= 000
         I/O Timings: shared read=3D70153.578
         ->  Index Scan using idx_poslog_p= ublisher_stage_status_error_retry_count_modi_date_c on poslog_publisher_rms= _stage ppse  (cost=3D0.57..10.91 rows=3D1 width=3D1019) (actual time= =3D59431.789..59431.790 rows=3D0 loops=3D1)
               Index Cond: (((statu= s)::text =3D ANY ('{UNPROCESSED,FAILED}'::text[])) AND (error_retry_count &= lt; 3))
               Buffers: shared hit= =3D1286676 read=3D1734000
               I/O Timings: shared = read=3D70153.578
 Planning Time: 0.114 ms
 Execution Time: 59431.839 ms 

Total blocks reads increased from 18k to 3 million.  n_tup_ins, n_tup_= del, n_live_tup, and n_dead_tup all increased by 10,320 over that 15 minute= period of time.  

What is going on here where this query has to do 3+ million block reads to = find 0 rows?  And how is it possible when I run the query 2 times in a= row the logical reads from the 2nd run comes down significantly?  Is = this somehow related to determining if rows are visible or something like that?  When I waited 15 minutes between= runs the inserted/updated rows only increased by 10.3k yet total block rea= ds increased by 3 million.

Thanks
--_000_BYAPR06MB447199DE1FCF363EF389EF1A8A362BYAPR06MB4471namp_-- From laurenz.albe@cybertec.at Tue Apr 28 05:33:24 2026 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wHb4e-007Kzz-19 for pgsql-performance@arkaria.postgresql.org; Tue, 28 Apr 2026 05:33:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wHb4c-00GEmQ-0G for pgsql-performance@arkaria.postgresql.org; Tue, 28 Apr 2026 05:33:30 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wHb4b-00GEmI-1y for pgsql-performance@lists.postgresql.org; Tue, 28 Apr 2026 05:33:29 +0000 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wHb4Y-000000038lA-3bD6 for pgsql-performance@lists.postgresql.org; Tue, 28 Apr 2026 05:33:28 +0000 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-488a8ca4aadso152016985e9.3 for ; Mon, 27 Apr 2026 22:33:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1777354406; x=1777959206; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=fri30hjCnTQKNOEXPWQLgdx13E2/GnI1f8RkY4n7Hww=; b=jX9yJQGqANDk3jGV0DRoJtehF/vAZq5GW3rqvKZxSVtLuC11nIj+pb3qryZliG6wEG mY9su0uf7CwSf+c9MHIjuhcyDHbUtjODoR25wkAG7cHet8uXgvwSk9i4QYsX3jCFn5tJ MZaGmvYM9vYubUJcDb8+RPoYJrtB03C1x1tchV+VbzDo7d+K9E08Hx+7JMwOQqFzQS99 mCx3TINAjcIvrPHGauA9o1NkBweBnT6GjSvMAgvvyKZqRofivyD5h/v16vHlM7p2mvOY Vq8ZGxLbjwBIXfKZcsmzkrwRqP9kBngdHoxp1kOS2lzPIOvUsO8k34jpkYW7XK/0a1UW /LHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777354406; x=1777959206; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fri30hjCnTQKNOEXPWQLgdx13E2/GnI1f8RkY4n7Hww=; b=KO/Sw3PYGDb5JuENTK5axIoqOSyDX+fEUnW9q0GlNRkNP7yrJ8CUKKA5Pnl4onuRuk 7cSHtZqoL8z1qCwxumvzi69Vdfhf1XX0gGRVqwIivaWFC29xW/rZpHLEM6sZPGmEMaAL xdT+jUuEAY3/JBOCRb8IDfbEK7fpL34c44VraiQ753sflR+XbRj8InMxNzaXuh4AlNDC 5JIGxTgMZRNjOED9Zwa7GcRAvHlG/TpAiH/ptUCPs8iF2iFA0xdnmZt6TQ34Qf/hbg8r EV8v984jFyd6OSYtQY0TFLTRzQvOTzZ3WQJ74bustg+HNqD3N9NsbwdXtWyIm8NZpUPb 8Hug== X-Forwarded-Encrypted: i=1; AFNElJ/+KyVhlbJzZAe/9G1ITZJUr9b8vgMi2X7z/Cy7SGqeyyBMJw6DHMOUDqeFeJs4OEfdBOFMTWnLBcmTNQ6R9disfA==@lists.postgresql.org X-Gm-Message-State: AOJu0YwIiw5zGNsQSKzNLN5gCvn5KrYTazDkq+1+vQuDUU0qxsdtap1R 9BCEcPQRWlCA8qf/GZhc4eys0lK9tNGJYuVm0sq/nKXBE881dPfl1OZo5Z6D1OtA4BI= X-Gm-Gg: AeBDiesEggjt/bkwri7p7wSVOlC7poDMPL2yx7MMOswbTbPYqi2dVs6QvtnM3ANiEON im+UithSl826DE0w2J/FZz5aCGfeQBSKrTLoiMo8KgYf1f5a+0bFvynOcwRcvoru8QBtU+ZZdJi W4rTNFY90jYYZwAfurMdFJ72/Gsvhj0zqhEgsy38JgatKeCvaR4mqFtLBG85gst2r0jMfh0Mepu +bOmrcTjaCVPi5CzzQxkH6Uheh/HfC/kvkWjfffkdhQTkK2LXQZlZ7Hst0jDToS/+UxeviFlNQ8 qLG5rZ4z0X/u1o60JpeJXXrRByf7RGRCg7r7JJkSY6Xz4POlKaeJkhH6tG24VvgEw7i2K1YLrPF 8bKizBfQ2z5jxXzWL/hJ2LEmAlDtcHu2VlypLt9NqHG6EDjOxaTIqalYUMuUCU9OzmlcGsuxmyX A+1plnIrMVtEPlGZWSZbGfwybF+X933R75CoCiL7YSutSLdKOt3w+nE9q+rmWefLeJFg== X-Received: by 2002:a05:600c:3b15:b0:487:1108:48af with SMTP id 5b1f17b1804b1-48a77ae5412mr24428825e9.4.1777354405770; Mon, 27 Apr 2026 22:33:25 -0700 (PDT) Received: from laurenz.albe-K4N0CV00F97414D ([2001:871:270:4fd5:603f:45c2:9807:c104]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48a77442889sm11178625e9.0.2026.04.27.22.33.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Apr 2026 22:33:25 -0700 (PDT) Message-ID: Subject: Re: Query performance From: Laurenz Albe To: "Dirschel, Steve-CW" , "pgsql-performance@lists.postgresql.org" Date: Tue, 28 Apr 2026 07:33:24 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.3 (3.58.3-1.fc43) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2026-04-27 at 15:52 +0000, Dirschel, Steve-CW wrote: > Aurora Postgres version 17.4. Aurora works quite differently, as far as storage is concerned, so you may = be suffering from some peculiarity of that closed source software. > Table in question: >=20 >=20 > \d poslog_publisher_rms_stage > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Tabl= e "public.poslog_publisher_rms_stage" > =C2=A0 =C2=A0 =C2=A0 Column =C2=A0 =C2=A0 =C2=A0 | =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 Type =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | Collation | Nullabl= e | Default > -------------------+--------------------------+-----------+----------+---= ------ > =C2=A0stage_id =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| uuid =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 | not null | > =C2=A0status =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| character varying= (100) =C2=A0 | =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0| > =C2=A0message_body =C2=A0 =C2=A0 =C2=A0| text =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 | not null | > =C2=A0error_code =C2=A0 =C2=A0 =C2=A0 =C2=A0| character varying(100) =C2= =A0 | =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0| > =C2=A0error_category =C2=A0 =C2=A0| character varying(100) =C2=A0 | =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| > =C2=A0error_message =C2=A0 =C2=A0 | text =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= | =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| > =C2=A0error_retry_count | integer =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0| =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0| 0 > =C2=A0create_date =C2=A0 =C2=A0 =C2=A0 | timestamp with time zone | =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | not null | now() > =C2=A0modified_date =C2=A0 =C2=A0 | timestamp with time zone | =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 | not null | now() > Indexes: > =C2=A0 =C2=A0 "poslog_publisher_rms_stage_pkey" PRIMARY KEY, btree (stage= _id) > =C2=A0 =C2=A0 "idx_poslog_publisher_stage_create_date_col" btree (create_= date) > =C2=A0 =C2=A0 "idx_poslog_publisher_stage_status_error_retry_count_modi_d= ate_c" btree (status, error_retry_count, modified_date) > Referenced by: > =C2=A0 =C2=A0 TABLE "poslog_publisher_rms_detail" CONSTRAINT "fk_poslog_p= ublisher_detail_stage_id" FOREIGN KEY (stage_id) REFERENCES poslog_publishe= r_rms_stage(stage_id) > Publications: > =C2=A0 =C2=A0 =E2=80=9Csashpsrms_publication" >=20 > The table is constantly getting loaded into. =C2=A0Rows are inserted with= a status ready and > then there is a different process looking for that status and will update= to processed > after processing the row. =C2=A0We have multiple tables like this. >=20 > Then every 2 hours a different process runs this query looking for failed= or unprocessed rows: >=20 > select > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 ppse.stage_id as stageId, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 ppse.status as status, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 ppse.message_body as messageBody > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 fro= m > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 poslog_publisher_rms_stage ppse > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 whe= re > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 ppse.status in ('UNPROCESSED','FAILED') > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 and ppse.error_retry_count < 3 > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ord= er by > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 ppse.create_date > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 lim= it 100; >=20 > If I run that query with explain it is doing a ton of work to find 0 rows= . =C2=A0The index it > uses seems appropriate for the query. The index can be used, but it is far from perfect. The ideal index would b= e: CREATE INDEX ON poslog_publisher_rms_stage (create_date) WHERE status in ('UNPROCESSED','FAILED') AND error_retry_count < 3; > =C2=A0=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0QUERY PLAN > -------------------------------------------------------------------------= ---------------------------------------------------------------------------= --------------------------------------------------------------------- > =C2=A0Limit =C2=A0(cost=3D10.92..10.93 rows=3D1 width=3D1019) (actual tim= e=3D66566.823..66566.824 rows=3D0 loops=3D1) > =C2=A0 =C2=A0Buffers: shared hit=3D1509768 read=3D2011479 > =C2=A0 =C2=A0I/O Timings: shared read=3D79792.017 > =C2=A0 =C2=A0-> =C2=A0Sort =C2=A0(cost=3D10.92..10.93 rows=3D1 width=3D10= 19) (actual time=3D66566.821..66566.821 rows=3D0 loops=3D1) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Sort Key: create_date > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Sort Method: quicksort =C2=A0Memory: 25= kB > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Buffers: shared hit=3D1509768 read=3D20= 11479 > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0I/O Timings: shared read=3D79792.017 > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-> =C2=A0Index Scan using idx_poslog_pu= blisher_stage_status_error_retry_count_modi_date_c on poslog_publisher_rms_= stage ppse =C2=A0(cost=3D0.57..10.91 rows=3D1 width=3D1019) (actual time=3D= 66566.761..66566.761 rows=3D0 loops=3D1) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Index Cond: (((sta= tus)::text =3D ANY ('{UNPROCESSED,FAILED}'::text[])) AND (error_retry_count= < 3)) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Buffers: shared hi= t=3D1509765 read=3D2011479 > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0I/O Timings: share= d read=3D79792.017 > =C2=A0Planning: > =C2=A0 =C2=A0Buffers: shared hit=3D195 read=3D1 > =C2=A0 =C2=A0I/O Timings: shared read=3D1.038 > =C2=A0Planning Time: 2.909 ms > =C2=A0Execution Time: 66581.498 ms >=20 > The query did 3.5 million block reads when scanning the index of which 1.= 5 million were > in memory and 2 million were from disk. =C2=A05 seconds later I ran the e= xact same query again: >=20 > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 QUERY PLAN > -------------------------------------------------------------------------= ---------------------------------------------------------------------------= --------------------------------------------------------------- > =C2=A0Limit =C2=A0(cost=3D10.92..10.93 rows=3D1 width=3D1019) (actual tim= e=3D23.589..23.591 rows=3D0 loops=3D1) > =C2=A0 =C2=A0Buffers: shared hit=3D18736 > =C2=A0 =C2=A0-> =C2=A0Sort =C2=A0(cost=3D10.92..10.93 rows=3D1 width=3D10= 19) (actual time=3D23.588..23.589 rows=3D0 loops=3D1) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Sort Key: create_date > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Sort Method: quicksort =C2=A0Memory: 25= kB > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Buffers: shared hit=3D18736 > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-> =C2=A0Index Scan using idx_poslog_pu= blisher_stage_status_error_retry_count_modi_date_c on poslog_publisher_rms_= stage ppse =C2=A0(cost=3D0.57..10.91 rows=3D1 width=3D1019) (actual time=3D= 23.583..23.584 rows=3D0 loops=3D1) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Index Cond: (((sta= tus)::text =3D ANY ('{UNPROCESSED,FAILED}'::text[])) AND (error_retry_count= < 3)) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Buffers: shared hi= t=3D18736 > =C2=A0Planning Time: 0.118 ms > =C2=A0Execution Time: 23.628 ms >=20 > Now it only did 18k block reads all in memory. =C2=A0It used the same ind= ex, it also > returned 0 rows. =C2=A0Between those 2 runs I looked at pg_stat_user_tabl= es and could see the > n_tup_ins increased by 13, n_tup_del increased by 13, n_live_tup increase= d by 13, and > n_dead_tup increased by 13. =C2=A0n_live_tup was 96 million and n_dead_tu= p was 8.4 million. > 18k logical reads to find 0 rows is still high but I believe that is most= likely caused > by the 8.4 million n_dead_tups. >=20 > What is going on here where this query has to do 3+ million block reads t= o find 0 rows? > And how is it possible when I run the query 2 times in a row the logical = reads from the > 2nd run comes down significantly? =C2=A0Is this somehow related to determ= ining if rows are > visible or something like that? The only way I can imagine this happening in PostgreSQL is if the first exe= cution kills a lot of index tuples (https://www.cybertec-postgresql.com/en/killed-= index-tuples/). > When I waited 15 minutes between runs the inserted/updated rows only incr= eased by > 10.3k yet total block reads increased by 3 million. Now that seems to speak against the above theory, so you are suffering from= some Amazon- specific behavior. Yours, Laurenz Albe