pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Kristjan Mustkivi <sonicmonkey@gmail.com>
Cc: Jeff Janes <jeff.janes@gmail.com>
Cc: Tomas Vondra <tomas.vondra@enterprisedb.com>
Cc: Pgsql Performance <pgsql-performance@lists.postgresql.org>
Subject: Re: Postgres chooses slow query plan from time to time
Date: Tue, 14 Sep 2021 11:47:21 -0400
Message-ID: <632224.1631634441@sss.pgh.pa.us> (raw)
In-Reply-To: <CAOQPKauv_5UnjzQuQRovuHJQ45JpmWcoXHEU5WsWJ5HtgtBbGg@mail.gmail.com>
References: <CAOQPKavhdTrgQo8Uss0M+K0Du+_WYmdoGyMpC0hJQkKM+-X25Q@mail.gmail.com>
	<31c01752-c4d6-7751-9d25-b1fac8f3a7aa@enterprisedb.com>
	<CAOQPKasCkSAW6FTt_iCY1Ts8tUgT+mf+jro46QXE50eVAQ6Pvg@mail.gmail.com>
	<CAMkU=1zp56=kfsQMxfrEyVn4sxOY1HH3GPoANN5rGKUHvW4S7w@mail.gmail.com>
	<CAOQPKati1jk6PniYNcodoC6T=4+ZrWxnmoVHOJe92-BpMsRHmg@mail.gmail.com>
	<589350.1631628930@sss.pgh.pa.us>
	<CAOQPKauv_5UnjzQuQRovuHJQ45JpmWcoXHEU5WsWJ5HtgtBbGg@mail.gmail.com>

Kristjan Mustkivi <sonicmonkey@gmail.com> writes:
>>> Filter: (((product_code)::text = ($1)::text) AND
>>> ((balance_type)::text = ($4)::text))

> But the Primary Key is defined as btree (cage_code, cage_player_id,
> product_code, balance_type, version) so this should be exactly that
> (apart from the extra "version" column).

Oh, interesting.  So this is really a datatype mismatch problem.
I'd wondered idly why you were getting the explicit casts to text
in these conditions, but now it seems that that's key to the
problem: the casts prevent these clauses from being matched to
the index.  What are the declared data types of product_code
and balance_type?  And of the parameters they're compared to?

			regards, tom lane





view thread (19+ messages)  latest in thread

Message-ID: <632224.1631634441@sss.pgh.pa.us>
Permalink:  ../632224.1631634441@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/632224.1631634441@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, sonicmonkey@gmail.com, jeff.janes@gmail.com, tomas.vondra@enterprisedb.com, pgsql-performance@lists.postgresql.org
  Subject: Re: Postgres chooses slow query plan from time to time
  In-Reply-To: <632224.1631634441@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox