PostgreSQL: Slow JOIN on three large tables
Edit: Proposed this question as a LEFT JOIN problem, but as @wildplasser pointed out, due to my WHERE clause I was actually doing a JOIN all along. Adjusting the question from LEFT JOIN to JOIN. The...
View ArticleResetting deadlock count statistics
It seems that just restarting the PostgreSQL service doesn’t clear / reset the detected deadlock count. How can it be restarted to zero? select version(); PostgreSQL 9.4.5 on x86_64-unknown-linux-gnu,...
View Articledatabase Deadlock again
Once again I have a deadlock problem with the following log: [17/03/16 16:42:20.020 -0300] FATAL OPERACIONES: SQLException: CreateEquipo: ERROR: deadlock detected Detail: Process 2923 waits for...
View ArticlePostgres 9.4 to 9.5 using Yum and pg_upgrade – CentOS 6.7 (Final)
I am attempting to do an upgrade between Postgres 9.4 to 9.5 on a CentOS 6.7 system. I have reviewed both:...
View Articlepg_dump fails to create a backup when running from System User in Windows...
I am trying to run a pg_dump through a scheduled task in windows. I have two batch files. One creates the task. The other one runs the pg_dump. Even though the pg_dump works with the current user with...
View ArticleSELECT very slow when no results and a LIMIT is specified
I am running into an issue where a SELECT query is very slow because it does not use an index when the number of final results is 0 and a LIMIT clause is specified. If the number of results is greater...
View ArticleTrouble with group by on multiple column
For debugging purpose, i’m computing stocks of my application in order to be able to update them to the right values or to compare with current value. My objects are built as follow : location which...
View ArticleOne connection vs multi connection
I’m redesigning my client’s website in order to add about 16 mini sites for their web site. It’s a website using PostgreSQL. And my question is: Performance wise, what is the better database design: 1...
View ArticleUsing postgres with logstash – log filename is causing issues
I’m having some trouble forwarding postgres logs to logstash. Normally it’s pretty easy to do, but the problem with postgres is that the current logfile has the current date in the filename, so the...
View ArticleOptimizing “random” choice in PostgreSQL
I have the following table CREATE TABLE article ( id bigserial PRIMARY KEY, text TEXT NOT NULL, category_id bigint REFERENCES categories (id), status TEXT NOT NULL, locale TEXT NOT NULL, source TEXT...
View ArticleCalculate rolling sum over 7 consecutive day period on PostgreSQL
I need to get the rolling sum over a period of 7 days for each row (1 row per day). For example: | Date | Count | 7-Day Rolling Sum | ------------------------------------------ | 2016-02-01 | 1 | 1 |...
View ArticlePostgres: querying jsonb array with an array
My products table has a jsonb column called ‘specs’. This specs hash will often have an array field, let’s call it ‘spec_options’. When querying this table, I need to find any product that has certain...
View ArticleCompare the tablespace concept between Postgres and Oracle
When I create a table, it is placed in a default tablespace such as “USERS”, unless I specify a user created tablespace, say, MyTableSpace. For example, create table test_tab( name varchar2(100), photo...
View ArticleHow to verify disk hit by a query
I want to know how to verify disk hits by a select query in PostgreSQL 9.4 on CentOS 6.5. Also please let me know how far enabling the log_statement_stats in the postgresql.conf will help me. I need to...
View ArticlePostgreSQL 9.4.6 under RHEL 7 – Extensive logfile because of...
I got a newly installed database (PG 9.4.6 / RHEL 7) which logfile grows rapidly. Most entries are like 2016-03-03 10:33:29.259 CET [56868] user@db STATEMENT: SELECT field1 AS a1, field2 AS a2, field3...
View ArticlePostgresql server is running, but service appears stopped
I am running Postgresql 9.4 as a service on Windows Server 2008 R2. It usually works as a charm, but now there is a situation when the server is apparently running (I can connect to it, Task Manager...
View ArticleMeasure CPU and Memory usage while running pgbench
what is the best way to capture the usage of CPU and memory while running pgbench? The only way I can think of is to read the info from top header. what I do now I run top command by print it out in a...
View ArticleHow to create an index to be picked by query
I have created multiple indexes one after another, but my query doesn’t want to pick them CREATE INDEX x ON gan.paid (project_id, country_iso_code, source, date(created_at)); CREATE INDEX x ON gan.paid...
View ArticleUpgrade PostgreSQL 9.4 to 9.5 : LC_ALL unset
I’m trying to upgrade my PostgreSQL 9.4 database to PostgreSQL 9.5 but everytime while running sudo pg_upgradecluster 9.4 main I get this error: Stopping old cluster... Disabling connections to the old...
View Articlepgbouncer 1.7 with TLS/SSL client and server connections
With settings borrowed from a similar server running Postgres 9.4.1 & pgbouncer 1.6.1, I have multiple users connecting to the database through pgbouncer on port 6543. I also have a second server...
View Article