cache lookup failed for statistics object 123

Started by Justin Pryzbyover 5 years ago3 messageshackers
Jump to latest
#1Justin Pryzby
pryzby@telsasoft.com

Per sqlsmith.

postgres=# SELECT pg_get_statisticsobjdef_expressions(123);
ERROR: cache lookup failed for statistics object 123
postgres=# \errverbose
ERROR: XX000: cache lookup failed for statistics object 123
LOCATION: pg_get_statisticsobjdef_expressions, ruleutils.c:1762

The expectation is that sql callable functions should return null rather than
hitting elog().

In the 003 patch, I wonder if this part should be updated, too:

| ... which can greatly improve query plans that use the expression index.

It can improve queries even that don't use the index, right ?
Say, if a query has f(x) = 11, and the MCV list for the expression shows that
50% of the table has f(x)=11, then the query might decide to *not* use an index
scan.

--
Justin

Attachments:

0001-Return-NULL-rather-than-elog-ERROR-for-sql-callable-.patchtext/x-diff; charset=us-asciiDownload+2-3
0002-Comment-typos-extended-stats-a4d75c86b-and-518442c7f.patchtext/x-diff; charset=us-asciiDownload+2-3
0003-Mention-statistics-objects.patchtext/x-diff; charset=us-asciiDownload+2-2
#2Tomas Vondra
tomas.vondra@enterprisedb.com
In reply to: Justin Pryzby (#1)
Re: cache lookup failed for statistics object 123

Hi,

On 5/5/21 11:09 PM, Justin Pryzby wrote:

Per sqlsmith.

postgres=# SELECT pg_get_statisticsobjdef_expressions(123);
ERROR: cache lookup failed for statistics object 123
postgres=# \errverbose
ERROR: XX000: cache lookup failed for statistics object 123
LOCATION: pg_get_statisticsobjdef_expressions, ruleutils.c:1762

The expectation is that sql callable functions should return null rather than
hitting elog().

Right, thanks for noticing this.

In the 003 patch, I wonder if this part should be updated, too:

| ... which can greatly improve query plans that use the expression index.

It can improve queries even that don't use the index, right ?

Say, if a query has f(x) = 11, and the MCV list for the expression shows that
50% of the table has f(x)=11, then the query might decide to *not* use an index
scan.

Yeah, it should talk about improving estimates, it's mostly unrelated to
using indexes.

regards

#3Tomas Vondra
tomas.vondra@enterprisedb.com
In reply to: Tomas Vondra (#2)
Re: cache lookup failed for statistics object 123

I've pushed all three patches, with some better commit messages etc.

thanks!

--
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company