public inbox for [email protected]  
help / color / mirror / Atom feed
From: Greg Sabino Mullane <[email protected]>
To: Wong, Kam Fook (TR Technology) <[email protected]>
Cc: pgsql-general <[email protected]>
Subject: Re: Will hundred of thousands of this type of query cause Parsing issue
Date: Fri, 13 Sep 2024 15:04:40 -0400
Message-ID: <CAKAnmmKbnPSpzJ45N5314=nFDUtsAjwVPkxLCm87v_3qs9z09A@mail.gmail.com> (raw)
In-Reply-To: <CH0PR03MB610085FA248C69CDB73494FFFE652@CH0PR03MB6100.namprd03.prod.outlook.com>
References: <CH0PR03MB610085FA248C69CDB73494FFFE652@CH0PR03MB6100.namprd03.prod.outlook.com>

On Fri, Sep 13, 2024 at 11:35 AM Wong, Kam Fook (TR Technology) <
[email protected]> wrote:

> 1) Where does query parsing occur?
>
>
Always on the server side, although your driver may do something as well.

2) Will this cause extra parsing to the posgress DB?
>

Yes


>   Any pg system table to measure parsing?
>

No

You want to send an array of values to the same query, so it can be
prepared once, like so:

SELECT abc, efg
FROM docloc a
JOIN collection b USING (collection_name)
WHERE a.column1 = ANY($1)
AND a.stage_id = (
  select max(stage_id) from collection_pit c
  where c.collection_name = a.collection_name
  and c.pid_id < $2 and c.stage_code = $3
);

Then you can always pass in three arguments, the first being an array of
all the column1 values you want.

You might also want to get familiar with plan_cache_mode:
https://www.postgresql.org/docs/current/sql-prepare.html

Cheers,
Greg


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: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: Will hundred of thousands of this type of query cause Parsing issue
  In-Reply-To: <CAKAnmmKbnPSpzJ45N5314=nFDUtsAjwVPkxLCm87v_3qs9z09A@mail.gmail.com>

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

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