While running a maintenance script (doing VACUUM FULL ANALYZE and REINDEX on all tables of a database), the script spat out a lot of errors like these (here with the maintenance tasks manually launched):
postgres@pgserver:~$ psql mydb -c 'VACUUM FULL ANALYZE TB_78C957_LABELS'
ERROR: relation "tb_78c957_labels" does not exist
postgres@pgserver:~$ psql mydb -c 'REINDEX TABLE TB_78C957_LABELS'
ERROR: relation "tb_78c957_labels" does not exist
Interestingly the maintenance tasks worked on all lowercase tables while the "relation 'table' does not exist" error showed up on all the tables with uppercase names.
I was unable to find a reason of this error showing up related to VACUUM or REINDEX, but could find related errors when using capital or mixed-letter tables names:
the table is defined with a mixed-case spelling, and you're trying to query it with all lower-case
Although this is not the case here, it gives an important hint: The spelling matters! PostgreSQL uses lower-case naming by default. From the PostgreSQL Gotchas:
All unquoted identifiers are assumed by PostgreSQL to be lower case by default.
That means: The uppercase (and mixed case) table names need to be quoted:
postgres@pgserver:~$ psql mydb -c 'VACUUM FULL ANALYZE "TB_78C957_LABELS"'
VACUUM
postgres@pgserver:~$ psql mydb -c 'REINDEX TABLE "TB_78C957_LABELS"'
REINDEX
VoilĂ , no error anymore.
No comments yet.
AWS Android Ansible Apache Apple Atlassian BSD Backup Bash Bluecoat CMS Chef Cloud Coding Consul Containers CouchDB DB DNS Database Databases Docker ELK Elasticsearch Filebeat FreeBSD Galera Git GlusterFS Grafana Graphics HAProxy HTML Hacks Hardware Icinga Influx Internet Java KVM Kibana Kodi Kubernetes LVM LXC Linux Logstash Mac Macintosh Mail MariaDB Minio MongoDB Monitoring Multimedia MySQL NFS Nagios Network Nginx OSSEC OTRS Observability Office OpenSearch PGSQL PHP Perl Personal PostgreSQL Postgres PowerDNS Proxmox Proxy Python Rancher Rant Redis Roundcube SSL Samba Seafile Security Shell SmartOS Solaris Surveillance Systemd TLS Tomcat Ubuntu Unix VMWare VMware Varnish Virtualization Windows Wireless Wordpress Wyse ZFS Zoneminder