Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g0ifD-0004fq-00 for pgsql-bugs@arkaria.postgresql.org; Fri, 14 Sep 2018 07:37:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g0ifB-0005TF-0Q for pgsql-bugs@arkaria.postgresql.org; Fri, 14 Sep 2018 07:37:13 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g0h6y-0003Jd-9q for pgsql-bugs@lists.postgresql.org; Fri, 14 Sep 2018 05:57:48 +0000 Received: from mx1.datakom.lv ([158.255.56.65]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g0h6q-00005F-AP for pgsql-bugs@postgresql.org; Fri, 14 Sep 2018 05:57:46 +0000 X-AuditID: c0a8dc08-113ff700000011f4-d1-5b9b4dcf9e0e Received: from mx1.datakom.lv (Unknown_Domain [192.168.220.25]) (using TLS with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.datakom.lv (SMTP) with SMTP id 12.B4.04596.FCD4B9B5; Fri, 14 Sep 2018 08:57:35 +0300 (EEST) Received: from SRVEX01.datakom.lv (192.168.220.25) by SRVEX01.datakom.lv (192.168.220.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1531.3; Fri, 14 Sep 2018 08:59:50 +0300 Received: from SRVEX01.datakom.lv ([fe80::5d31:8f68:4138:7629]) by SRVEX01.datakom.lv ([fe80::5d31:8f68:4138:7629%5]) with mapi id 15.01.1531.003; Fri, 14 Sep 2018 08:59:50 +0300 From: =?windows-1257?Q?Mareks_Kalna=E8s?= To: Tom Lane CC: Victor Yegorov , "pgsql-bugs@postgresql.org" , =?windows-1257?Q?M=E2ris_Rucis?= , =?windows-1257?Q?P=E2vels_Kor=FEs?= Subject: RE: PostgreSQL 10.0 SELECT LIMIT performance problem Thread-Topic: PostgreSQL 10.0 SELECT LIMIT performance problem Thread-Index: AdRKcrcxKsJ4mGzUR4mNVsCT/UUnVQACLeMAAAfHS+AAAQD+AAAqXvjAAAn58gAAH9v0QA== Date: Fri, 14 Sep 2018 05:59:50 +0000 Message-ID: References: <7419b7a3a21d4f1c8509178a071ec636@datakom.lv> <803c5396974a42849ebec62bfa47f2c8@datakom.lv> <12108.1536860530@sss.pgh.pa.us> In-Reply-To: <12108.1536860530@sss.pgh.pa.us> Accept-Language: en-GB, lv-LV, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [192.168.230.57] Content-Type: text/plain; charset="windows-1257" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuplkeLIzCtJLcpLzFFi42I5sOKOpO5539nRBtePq1lc6J3LbHFq1V0m i3s717M5MHvsnHWX3ePCvmnsHouebWQJYI7isklJzcksSy3St0vgyrj+dSVTwTTpivUbr7I1 MP4X62Lk5JAQMJFo7J3N3sXIxSEkMIlJYuGTm2wQzktGib4T2xkhnG2MEscOfgdyODjYBFwl 3ncogHSLCChI9D14B9bNLPCAUeLnvbNsIAlhAVuJjX1XGSGK7CTmz9zMDmGHSZx7dYwJZA6L gKpE5xpbkDCvgKXE6r6TUItPMUl8fHUVrIZTQFfi82VVkBpGARWJd193go1hFhCXuPVkPhPE BwISS/acZ4awRSVePv7HCmErSZx9c4gJot5A4sCZpYwQtrbEsoWvmSH2CkqcnPmEZQKj2Cwk Y2chaZmFpGUWkpYFjCyrGPmLc9MN9VISSxKz83P1cso2MUIiiWMH47UvgYcYBTgYlXh4P7ye FS3EmlhWXJl7iFGCg1lJhHd9KFCINyWxsiq1KD++qDQntfgQozQHi5I479+GsmghgfTEktTs 1NSC1CKYLBMHp1QDY5zIIZapf7ddbazTyWx81PWVsbUw6HuD6THfuyEZOx9vqmmzyanRdr8f ynt1/7JbZn78O87Milr3eaPnbukVxgGMDYUM26Xe8+uJ/2Zvm7rxUFXli06BhOZjs+r3lzNm TNa0eqj8de7ks4Ffztqn7Y5Z9p/j4MnMf7USi1c3x4ps5LTR37qsWImlOCPRUIu5qDgRACIy VAOgAgAA List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Actually Postgres trying to outsmart himself, I do not add COLLATE ;) Original trigger text CREATE INDEX idx_oss_alarms_dn ON oss_alarms ((jdata ->> 'dn')); Mareks -----Original Message----- From: Tom Lane Sent: ceturtdiena, 2018. gada 13. septembris 20:42 To: Mareks Kalna=E8s Cc: Victor Yegorov ; pgsql-bugs@postgresql.org; M=E2ris= Rucis ; P=E2vels Kor=FEs Subject: Re: PostgreSQL 10.0 SELECT LIMIT performance problem =3D?utf-8?B?TWFyZWtzIEthbG5hxI1z?=3D writes: > But we are using value indexes not a json index: > CREATE INDEX idx_oss_alarms_dn > ON oss_alarms > USING btree > ((jdata ->> 'dn'::text) COLLATE pg_catalog."default"); I think you're outsmarting yourself by including those COLLATE clauses. They don't do anything, since they're just selecting the default behavior --- but they're enough to make the planner not realize that stats collected= on the index expression would be applicable to a plain reference to oss_al= arms.jdata ->> 'dn'. In general you want the index expression to be spelle= d exactly the same way that you refer to the value in queries, else the sys= tem may not realize it's relevant. regards, tom lane ________________________________ =D0is elektronisk=E2 pasta s=FBt=EEjums un taj=E2 eso=F0ie dokumenti ir par= edz=E7ts tikai nor=E2d=EEtajam adres=E2tam(-iem). Tas satur konfidenci=E2lu= inform=E2ciju un var satur=E7t ar=EE privili=EC=E7tu inform=E2ciju. T=E2 s= atura piln=EEga vai da=EF=E7ja nesankcion=E7ta izpau=F0ana, izmanto=F0ana v= ai t=E2l=E2ka izplat=EE=F0ana jebk=E2d=E2 veid=E2 ir aizliegta. Ja =F0is el= ektronisk=E2 pasta s=FBt=EEjums sa=F2emts k=EF=FBdas d=E7=EF, l=FBdzam sazi= n=E2ties ar s=FBt=EEt=E2ju, nos=FBtot atbildes e-pasta v=E7stuli, un izdz= =E7st =F0o v=E7stuli. Dro=F0=EEbas apsv=E7rumu d=E7=EF SIA Datakom var veik= t elektronisk=E2 pasta s=FBt=EEjumu un tiem pievienoto dokumentu satura mon= itoringu. Ja vien =F0aj=E2 v=E7stul=E7 vai pievienotajos dokumentus nav nep= =E2rprotami teikts pret=E7jais, =F0is elektronisk=E2 pasta s=FBt=EEjums vai= tam pievienotie dokumenti nav uzskat=E2mi par SIA Datakom pied=E2v=E2jumu = sl=E7gt dar=EEjumu, ap=F2em=F0anos vai gatav=EEbu uz=F2emties saist=EEbas. = S=FBt=EEt=E2js: SIA Datakom, vienotais re=ECistr=E2cijas nr: 40103142605, J= uridisk=E2 adrese: Vien=EEbas gatve 109, R=EEga, LV-1058, Latvija This electronic transmission and attached documents is intended only for th= e addressee(s). It contains confidential information and may also contain p= rivileged information. If you are not an intended recipient, you may not us= e, read, retransmit, disseminate or take any action in reliance upon it. If= this electronic transmission is received in error, please contact the send= er by sending a reply e-mail and delete this message. SIA Datakom reserves = the right to monitor all e-mail communications through its networks. Unless= this letter or the accompanying documents clearly stated otherwise, by thi= s electronic transmission does not constitute a contract offer, a contract = amendment or an acceptance of a contract offer on behalf of the SIA Datakom= . Sender: SIA Datakom, registration number: 40103142605, Latvia. Registered= office: Vienibas gatve 109, Riga, LV-1058, Latvia ________________________________