Re: How to read query plan - Mailing list pgsql-performance

From Miroslav Šulc
Subject Re: How to read query plan
Date
Msg-id 4235C4EA.40704@startnet.cz
Whole thread Raw
In response to Re: How to read query plan  (Kaloyan Iliev Iliev <news1@faith.digsys.bg>)
List pgsql-performance
Kaloyan Iliev Iliev wrote:

> Hi,
>
> I have an idea about your problem. Will it be difficult not to change
> the entire code but only the queries? You can change type in the
> Postgres to bool. Then, when select data you can use a CASE..WHEN to
> return 'Y' or 'N' or even write a little function which accepts bool
> and returns 'Y' or 'N'. In this case in all your queries you will have
> to replace the select of bool field with select form the function.

Thank you for your suggestion. I had a private message exchange with
Harald Fuchs who suggested the same (except the function). Here is what
whe "exchanged":

Harald Fuchs wrote:

> If you can control the SELECTs, just use
>
>  SELECT CASE col WHEN true THEN 'Y' ELSE 'N' END
>
> instead of
>
>  SELECT col
>
> Thus you wouldn't need to change your application code.
>
>
I use single SELECT for both PostgreSQL and MySQL. I could use your
solution. It would just require some tagging of bool fields in SELECTs
so I could add the CASE statement in case I use PostgreSQL backend.

Miroslav

Attachment

pgsql-performance by date:

Previous
From: Kaloyan Iliev Iliev
Date:
Subject: Re: How to read query plan
Next
From: Tom Lane
Date:
Subject: Avoiding tuple construction/deconstruction during joining