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 1g7gv9-000220-DE for pgsql-general@arkaria.postgresql.org; Wed, 03 Oct 2018 13:10:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g7gv7-0005Om-IJ for pgsql-general@arkaria.postgresql.org; Wed, 03 Oct 2018 13:10:29 +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.89) (envelope-from ) id 1g7gv7-0005Of-AY for pgsql-general@lists.postgresql.org; Wed, 03 Oct 2018 13:10:29 +0000 Received: from smtp03.optiver.com ([195.246.114.70]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g7gv4-0006Md-Oz for pgsql-general@lists.postgresql.org; Wed, 03 Oct 2018 13:10:28 +0000 Received: from pps.filterd (smtp03.optiver.com [127.0.0.1]) by smtp03.optiver.com (8.16.0.21/8.16.0.21) with SMTP id w93D4iJ2004628 for ; Wed, 3 Oct 2018 15:10:25 +0200 Received: from opammb0561.comp.optiver.com (opammb0561.comp.optiver.com [10.131.160.1]) by smtp03.optiver.com with ESMTP id 2msy041bck-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Wed, 03 Oct 2018 15:10:25 +0200 Received: from opammb0562.comp.optiver.com (10.131.160.2) by opammb0561.comp.optiver.com (10.131.160.1) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Wed, 3 Oct 2018 15:10:24 +0200 Received: from opammb0562.comp.optiver.com ([fe80::a0e7:cd95:88ff:ba5b]) by opammb0562.comp.optiver.com ([fe80::a0e7:cd95:88ff:ba5b%17]) with mapi id 15.00.1263.000; Wed, 3 Oct 2018 15:10:24 +0200 From: Floris Van Nee To: "'pgsql-general@lists.postgresql.org'" Subject: GIN multi-column index Thread-Topic: GIN multi-column index Thread-Index: AdRbGPE5dN3ujuVKTOGcfamLyzclug== Date: Wed, 3 Oct 2018 13:10:24 +0000 Message-ID: <2312f8d2fb514fb38dc5c33ec9db5f38@opammb0562.comp.optiver.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.131.160.182] x-tm-as-product-ver: SMEX-11.0.0.1251-8.100.1062-24132.007 x-tm-as-result: No--18.687700-0.000000-31 x-tm-as-user-approved-sender: Yes x-tm-as-user-blocked-sender: No Content-Type: multipart/alternative; boundary="_000_2312f8d2fb514fb38dc5c33ec9db5f38opammb0562compoptiverco_" MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-10-03_07:,, signatures=0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --_000_2312f8d2fb514fb38dc5c33ec9db5f38opammb0562compoptiverco_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi, I've been looking at using GIN indices in some of my tables and was wonderi= ng something about their behavior when using them as a multi-column index. = Suppose we have a table 't' with column 'a' as int and column 'b' as int[].= Suppose we also have a query like: select * from t where a=3D1 and b@>'{2}' If I define a GIN index on (a, b) (with contrib extension btree_gin), will = this be a significant improvement over a GIN index just on b (significant m= eaning, a similar improvement to what you would expect for a btree multi-co= lumn index in a similar situation where the equality is tested on first col= umn and the second column is an inequality)? I know in a btree index the sp= eedup is generally significant as long as your left-most index column has a= n equality comparison, due to the way btree indices work. But I couldn't fi= nd information in the docs on how GIN indices behave in such a situation an= d why. -Floris --_000_2312f8d2fb514fb38dc5c33ec9db5f38opammb0562compoptiverco_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hi,

 

I’ve been looking at using GIN indices in some= of my tables and was wondering something about their behavior when using t= hem as a multi-column index. Suppose we have a table ‘t’ with c= olumn ‘a’ as int and column ‘b’ as int[]. Suppose w= e also have a query like:

select * from t where a=3D1 and b@>’{2}R= 17;

If I define a GIN index on (a, b) (with contrib exte= nsion btree_gin), will this be a significant improvement over a GIN index j= ust on b (significant meaning, a similar improvement to what you would expe= ct for a btree multi-column index in a similar situation where the equality is tested on first column and th= e second column is an inequality)? I know in a btree index the speedup is g= enerally significant as long as your left-most index column has an equality= comparison, due to the way btree indices work. But I couldn’t find information in the docs on how GIN= indices behave in such a situation and why.

 

-Floris

--_000_2312f8d2fb514fb38dc5c33ec9db5f38opammb0562compoptiverco_--