Re: understanding why two nearly identical queries take two different planner routes, one 5s and one 2hr

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: john gale <john(at)smadness(dot)com>
Cc: Shaun Thomas <sthomas(at)optionshouse(dot)com>, "pgsql-general(at)postgresql(dot)org general" <pgsql-general(at)postgresql(dot)org>
Subject: Re: understanding why two nearly identical queries take two different planner routes, one 5s and one 2hr
Date: 2014-08-06 16:59:38
Message-ID: CAMkU=1zQEsg14LB+5G5qaoQthS6-KmO36KsVkDwg=dbq2t61SA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Aug 5, 2014 at 2:08 PM, john gale <john(at)smadness(dot)com> wrote:

>
> >> -> Bitmap Index Scan on
> >> index_testruns_on_custom_spawnid (cost=0.00..41437.84 rows=500170
> >> width=0) (actual time=4872.404..4872.404 rows=2438520 loops=1)
> >
> > Ouch, ouch, and more ouch. Your index_testruns_on_custom_spawnid index
> on matched 2.5 million rows...
>
>
> Yes, although it's still better than the 40mil rows that we have in the
> table itself...
>
> Also, that doesn't make sense to me, since we don't have 2.5mil rows that
> match this one SpawnID. Could this suggest that my partial hstore index is
> somehow misconstructed? Or is that saying that 2.5mil rows have a SpawnID,
> not all of which will be the one I'm looking for?
>

Have you tripled checked that for 'SpawnID-428870395.258592' ?

That seems like something a human is much more likely to get wrong than a
computer is.

Anyway, it seems like an compound index on ((custom_data ->
'SpawnID'::text),started_at) could do wonders for this query.

Cheers,

Jeff

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Janes 2014-08-06 17:08:35 Re: Re: understanding why two nearly identical queries take two different planner routes, one 5s and one 2hr
Previous Message David G Johnston 2014-08-06 16:45:00 Re: Questions on dynamic execution and sqlca