Postgres INNER JOIN same table failing on CartoDB
I have a table with data which looks like this +----+------+-------+ | cp | year | count | +----+------+-------+ | 1 | 2000 | 10000 | | 1 | 2001 | 9000 | | 1 | 2002 | 9500 | | 2 | 2000 | 8000 | | 2 |...
View ArticleCan't create user in postgres
When I run CREATE USER username WITH PASSWORD 'test' in sudo -u postgres psql and run du only postgres user appears… I’m not prompted anything when running commands like ALTER USER and I know USER...
View ArticleIndex a Table with Geometry Column
I have a table called Stores with 10k rows which has a column location geometry(Point,4326). CREATE INDEX "Stores_spatial_gix" ON "Stores" USING gist (location); Upon KNN query explain analyze select *...
View Articlepostgresql – How to limit access to specific database only, and restrict...
I have a user test, which can view data from the system tables such as pg_class. The idea is to isolate him to have access to a specific database only and not have any access to system resources. The...
View ArticleOverlapping line aggregation+trim in PostGIS, while summing values
I’m sorry for the vague title, I didn’t really know how to name this. I am working on a project that visualizes and simulates 17th century trade. For this project we also use so called Minard lines to...
View ArticleMultiple queries in pgrouting (length as result)
I am facing the following problem with two tables: The first table contains all my streetnetwork with cost, source, target. Another table contains 60 nodes (from the above network). Between all these...
View ArticleWhat's better here – a single column or multicolumn primary key?
Let’s assume you have a table groups and a table item. Each item belongs to exactly one group. It is an inherent part of that group. An item cannot exist outside of a group and it cannot be moved to...
View ArticleSessionizing Log Data Using SQL window functions: tweaking a query...
I’m referencing to a very good blog entry, that describes how to sessionize log data with SQL window functions. I’m no database pro and I don’t really understand the logic behind this query (you can...
View ArticleDebug PostgreSQL lock count with check_postgres.pl
We use check_postgres.pl to monitor our database. We use this to check the count of the locks: https://bucardo.org/check_postgres/check_postgres.pl.html#locks We often see more than 150 locks. The...
View ArticleImprove the speed of a BETWEEN search
I have a query witch is selecting some data between two dates: SELECT * FROM rk.p_reports WHERE project_id = 1 AND engine_id = 1 AND type_id = 1 AND created_at::date BETWEEN now()::date - 14 AND...
View ArticleIs Drupal 8 with PostgreSQL supported?
Is the new Drupal 8 supported/certified by the Drupal community to run on PostgreSQL? This is the top hit, https://www.drupal.org/node/2157455 I don’t really know what that means here in the Open...
View ArticleHow to optimize query with max on Postgres?
I’m trying to make a relatively simple query, but it’s taking much longer than I’d expect. I have an index in place, but it doesn’t seem to be helping much. Here’s the query. It takes over an hour and...
View ArticleCould not locate a valid checkpoint record postgres
I have a database postgres in windows server and two slaves for reading. I need do Incremental Backup. What I’ve done: – Create Base Backup from pg_basebackup – Save WAL files Restore What remains to...
View Articleneed better db design for project
I have two tables: notes users Notes Table: id || description ||CreatedBy(which is userid)||......other columns --------------------------------------- Users table: id || name || ......other columns...
View ArticleSQLAlchemy connection error with Postgres
I am trying to write a basic python script that uses SQLAlchemy to connect to my Postgres database. In the connection details, if I use “LOCALHOST”, it connects fine. If I reference the server by name,...
View ArticleUsing an index on a Postgresql integer range causing trouble
Unfortunately I was not able to create a usable example / fiddle. But I am using a Postgresql 9.4 table that looks somewhat like this: CREATE TABLE table1 (id INT PRIMARY KEY NOT NULL, dtype TEXT,...
View ArticleMigrate Postgres from VM to VM
I have 2 VMs, both are identical in structural terms (came from the same snapshot, nothing installed, upgraded or removed). One VM is “clean”, never used. The other VMs was heavily used and it has some...
View ArticleOptimize a query with small LIMIT, predicate on one column and order by another
I’m using Postgres 9.3.4 and I have 4 queries that have very similar inputs but have vastly different response times: Query #1 EXPLAIN ANALYZE SELECT posts.* FROM posts WHERE posts.source_id IN (19082,...
View ArticleVisualising a raster PostgreSQL table in QGIS
I have imported a raster tif image into PostgreSQL with this command: raster2pgsql -s 32643 -I -M filepath.tif -F -t 100x100 public.databassename > filepath.sql And imported the output SQL file...
View Articlepg_stat_statements not found even with “shared_preload_libraries =...
I have followed the instructions given below: http://www.postgresql.org/docs/9.3/static/pgstatstatements.html … to the effect of adding the following lines: # postgresql.conf shared_preload_libraries =...
View Article