pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedReproducing query plans in empty database: can I just copy stats and settings?
5+ messages / 3 participants
[nested] [flat]
* Reproducing query plans in empty database: can I just copy stats and settings?
@ 2019-07-29 19:07 Guyren Howe <guyren@gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: Guyren Howe @ 2019-07-29 19:07 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
I work with Protected Health Information so have restricted access to an important database.
I would like to look into index and query changes for that database. It occurs to me that if I was able to reproduce the statistics and cost settings for the database, then Explain would produce identical results to the production database.
Can do this? Any other advice?
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Reproducing query plans in empty database: can I just copy stats and settings?
@ 2019-07-29 19:25 Adrian Klaver <adrian.klaver@aklaver.com>
parent: Guyren Howe <guyren@gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: Adrian Klaver @ 2019-07-29 19:25 UTC (permalink / raw)
To: Guyren Howe <guyren@gmail.com>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
On 7/29/19 12:07 PM, Guyren Howe wrote:
> I work with Protected Health Information so have restricted access to an
> important database.
>
> I would like to look into index and query changes for that database. It
> occurs to me that if I was able to reproduce the statistics and cost
> settings for the database, then Explain would produce identical results
> to the production database.
>
> Can do this? Any other advice?
So what defines restricted access?
If you can't see/use the data in the production database in your test
database I'm not sure how copying the statistics/cost settings is going
to help.
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Reproducing query plans in empty database: can I just copy stats and settings?
@ 2019-07-29 21:59 Guyren Howe <guyren@gmail.com>
parent: Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 1 reply; 5+ messages in thread
From: Guyren Howe @ 2019-07-29 21:59 UTC (permalink / raw)
To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
On Jul 29, 2019, at 12:25 , Adrian Klaver <adrian.klaver@aklaver.com> wrote:
>
> On 7/29/19 12:07 PM, Guyren Howe wrote:
>> I work with Protected Health Information so have restricted access to an important database.
>> I would like to look into index and query changes for that database. It occurs to me that if I was able to reproduce the statistics and cost settings for the database, then Explain would produce identical results to the production database.
>> Can do this? Any other advice?
>
> So what defines restricted access?
>
> If you can't see/use the data in the production database in your test database I'm not sure how copying the statistics/cost settings is going to help.
Isn’t that the entirety of what the query plan is based on? I was hoping I could then run Explain as if I had the data.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Reproducing query plans in empty database: can I just copy stats and settings?
@ 2019-07-29 22:08 Tom Lane <tgl@sss.pgh.pa.us>
parent: Guyren Howe <guyren@gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: Tom Lane @ 2019-07-29 22:08 UTC (permalink / raw)
To: Guyren Howe <guyren@gmail.com>; +Cc: Adrian Klaver <adrian.klaver@aklaver.com>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Guyren Howe <guyren@gmail.com> writes:
> On Jul 29, 2019, at 12:25 , Adrian Klaver <adrian.klaver@aklaver.com> wrote:
>> If you can't see/use the data in the production database in your test database I'm not sure how copying the statistics/cost settings is going to help.
> Isn’t that the entirety of what the query plan is based on?
No; physical sizes of the tables and indexes also matter. (The planner
scales some cost values by those numbers to account for the likelihood
that tables have grown since they were last analyzed.) You could deal
with that by bloating them with dummy data, of course.
I think though that Adrian's point is a bit different: if you're not
allowed to see the original data, you should not be allowed to see
the statistics either. The histogram values and most-common-values
lists represent a pretty sizable information leak for such cases.
regards, tom lane
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Reproducing query plans in empty database: can I just copy stats and settings?
@ 2019-07-29 23:04 Adrian Klaver <adrian.klaver@aklaver.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 5+ messages in thread
From: Adrian Klaver @ 2019-07-29 23:04 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; Guyren Howe <guyren@gmail.com>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
On 7/29/19 3:08 PM, Tom Lane wrote:
> Guyren Howe <guyren@gmail.com> writes:
>> On Jul 29, 2019, at 12:25 , Adrian Klaver <adrian.klaver@aklaver.com> wrote:
>>> If you can't see/use the data in the production database in your test database I'm not sure how copying the statistics/cost settings is going to help.
>
>> Isn’t that the entirety of what the query plan is based on?
>
> No; physical sizes of the tables and indexes also matter. (The planner
> scales some cost values by those numbers to account for the likelihood
> that tables have grown since they were last analyzed.) You could deal
> with that by bloating them with dummy data, of course.
>
> I think though that Adrian's point is a bit different: if you're not
> allowed to see the original data, you should not be allowed to see
> the statistics either. The histogram values and most-common-values
> lists represent a pretty sizable information leak for such cases.
Yeah that and access to the actual data. Not sure how you could run a
query that replicated the production(even with cloned stats) if the
table(s) are missing data. I could see throwing in dummy data, but it
would need to correlate with the actual data and you don't know what
that is. Then there is, what happens if you manually or
autovacuum/analyze the test data?
>
> regards, tom lane
>
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2019-07-29 23:04 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-07-29 19:07 Reproducing query plans in empty database: can I just copy stats and settings? Guyren Howe <guyren@gmail.com>
2019-07-29 19:25 ` Adrian Klaver <adrian.klaver@aklaver.com>
2019-07-29 21:59 ` Guyren Howe <guyren@gmail.com>
2019-07-29 22:08 ` Tom Lane <tgl@sss.pgh.pa.us>
2019-07-29 23:04 ` Adrian Klaver <adrian.klaver@aklaver.com>
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