Quantcast
Channel: Question and Answer » postgresql
Browsing all 1138 articles
Browse latest View live

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 Article


Can'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 Article


Index 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 Article

postgresql – 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 Article

Image may be NSFW.
Clik here to view.

Overlapping 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 Article


Multiple 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 Article

What'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 Article

Image may be NSFW.
Clik here to view.

Sessionizing 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 Article


Debug 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 Article


Improve 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 Article

Is 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 Article

How 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 Article

Could 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 Article


need 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 Article

SQLAlchemy 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 Article


Using 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 Article

Migrate 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 Article


Optimize 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 Article

Visualising 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 Article

pg_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
Browsing all 1138 articles
Browse latest View live