Skip to content

Queries covering deleted relations #15

@terrorobe

Description

@terrorobe

While rolling out pg_stat_plans on more databases I noticed problems with queries containing dropped relations:

bacula=# select * from pg_stat_plans where planid = 1305572066;
-[ RECORD 1 ]-------+---------------------------------------------------------------------------------
planid              | 1305572066
userid              | 16384
dbid                | 16386
query               | SELECT DISTINCT DelCandidates.JobId,DelCandidates.PurgedFiles FROM DelCandidates
had_our_search_path | t
from_our_database   | t
query_explainable   | t
calls               | 1
total_time          | 0.013
rows                | 2
shared_blks_hit     | 0
shared_blks_read    | 0
shared_blks_written | 0
local_blks_hit      | 1
local_blks_read     | 0
local_blks_written  | 0
temp_blks_read      | 0
temp_blks_written   | 0
blk_read_time       | 
blk_write_time      | 
last_startup_cost   | 34.9
last_total_cost     | 36.9

bacula=# \d DelCandidates
Did not find any relation named "DelCandidates".
bacula=# select pg_stat_plans_explain(1305572066, 16384, 16386);
ERROR:  relation "delcandidates" does not exist
LINE 1: ...elCandidates.JobId,DelCandidates.PurgedFiles FROM DelCandida...
                                                             ^
QUERY:  EXPLAIN SELECT DISTINCT DelCandidates.JobId,DelCandidates.PurgedFiles FROM DelCandidates
bacula=# 

Is it possible to set query_explainable to false for queries where one of the needed relations doesn't exist anymore/at the moment?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions