Multicolumn index for single-column queries?

From: rihad <rihad(at)mail(dot)ru>
To: pgsql-general General <pgsql-general(at)postgresql(dot)org>
Subject: Multicolumn index for single-column queries?
Date: 2019-04-18 06:52:00
Message-ID: 95ade9a3-6846-3f55-f936-85b8bb4b46a8@mail.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi. Say there are 2 indexes:

"foo_index" btree (foo_id)

"multi_index" btree (foo_id, approved, expires_at)

foo_id is an integer. Some queries involve all three columns in their WHERE clauses, some involve only foo_id.
Would it be ok from general performance standpoint to remove foo_index and rely only on multi_index? I know that
PG would have to do less work updating just one index compared to updating them both, but wouldn't searches
on foo_id alone become slower?

Thanks.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gavin Flower 2019-04-18 07:14:13 Re: Multicolumn index for single-column queries?
Previous Message Julie Nishimura 2019-04-18 04:38:43 Re: ERROR: operator class "gin__int_ops" does not exist for access method "gin"