substring index what is better way to query

From: Tieson Molly <tvmaly(at)gmail(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: substring index what is better way to query
Date: 2017-06-20 11:51:06
Message-ID: CADPSLQaAGZ6jxDhqmv2k5YcLiLXPSfdEU7c9wBEAQT40YAsH2w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Good morning,

I have an index I created on the prefix of a column:

create index location_geo_idx ON locations( substring(geohash, 0, 5));

I currently use a similar to query, but I wanted to know if there is a
faster way to query multiple value using this index than this?

select l.geohash from locations l where l.geohash similar to '(dr7g|dr7e)%';

My goal is to utilize 9 values each time for the geohash adjacent squares.

Best regards,

Ty

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2017-06-20 14:19:09 Re: substring index what is better way to query
Previous Message Stephen Frost 2017-06-16 12:05:37 Re: Using array instead of sub table (storage and speed)