Ravi Krishna <sravikrishna3@gmail.com> writes:
> Perhaps I was not clear. The planner is excluding partitions which can
> not contain the rows looked up in the WHERE clause. However it is
> still scanning the parent table.
Sure, because you don't have a constraint forbidding the parent from
having a matching row, no?
In older versions of PG there wasn't any way around this, but recent
versions allow you to mark a constraint as NO INHERIT, which would
let you attach such a constraint to the parent only.
By and large, though, this doesn't really matter, since an empty
parent table won't cost anything much to scan. If it's significant
relative to the child table access time then you probably didn't
need partitioning in the first place.
regards, tom lane