Postgres privileges: psql dp – what is about the plus-sign
I used psql-command “dp” to find out the given grants. Versions on test-server: PostgreSQL 9.1.15 on armv7l-unknown-linux-gnueabi, compiled by gcc (Debian 4.6.3-14) 4.6.3, 32-bit Out of the...
View ArticlePostgresql Hot Standby – How to determine it's fully mirrored?
I have set up a hot standby of a postgresql server. It all seems to be working, but I just want to be sure that I’m not missing something. In /var/lib/pgsql/9.2/data/pg_log/postgresql-Wed.log I have...
View ArticlePostgreSQL: how do I list all triggers that use a specific field?
for example i have a student table with (studentid) i want to get a list of triggers that use this field… for example if in table X there is a trigger that uses studentid i want it to be shown in the...
View Articleselect by location point in polygon with sql query
I have 2 tables table a this one a polygon layer with 10000 records table b this one a point layer with 600000 records in postgresql geodatabase i select a polygon feature with the query by input x and...
View ArticleBest index for similarity function
So I have this table with 6.2 millions records and I have to perform search queries with similarity for one for the column. The queries can be: SELECT "lca_test".* FROM "lca_test" WHERE...
View ArticleMoving postresql 9.1 database – live
This question has probably been asked and answered before, and if so, I would appreciate if that could be pointed out to me. I have googled this point quite a bit, but I want to be very sure as to what...
View ArticleQuery single column, all rows in Postgres 2D Array
Is there any way to fix the query below so I don’t have to specify an arbitrary max row count? DROP TABLE IF EXISTS array_test; CREATE TABLE array_test ( id serial primary key, name text, array_column...
View ArticleOptimize query with access to tiny fraction of data
I am trying to optimize some queries but I can only use a tiny portion of the actual data they will be executed against later. Probably the query optimizer will generate completely different plans when...
View ArticleBoolean check on fields returning any of them except if all have same value
Assuming we have 4 boolean fields a,b,c,d How can we return any of the fields that are true, but not nothing when all 4 are true? where a=true or b=true or c=true or d=true will return a row where even...
View ArticleHow to list all tables associated with specific foreign key?
I have this Postgresql query: select (select r.relname from pg_class r where r.oid = c.conrelid) as table, (select r.relkind from pg_class r where r.oid = c.conrelid) as type, (select...
View Articlepostgresql Insert into table B based on foreign key in table A, if exists in...
the scenario is as follows: I have an invoice and supplier table. The invoice references supplier on supplier_id. I want to insert into invoice. If supplier_company does not exist in the supplier...
View ArticlePostgres 9.4 – How to really grant all privileges on a database to another user?
Just a heads up, I’m fairly new at this whole DBA thing. Okay, with that out of the way I’ve been struggling mightily lately with granting access to a database in postgres to a user. Let’s call the...
View ArticleSlow query over 10mil rows with group by on indexed column
I’ve got a slow query which I want to optimize. SELECT pand.bouwjaar AS construction_date, count(*) FROM pand AS pand WHERE pand.begindatumtijdvakgeldigheid <= 'now'::text::timestamp without time...
View ArticleGetting an aggregate (here: min) for a group of values [closed]
Example table: ID | value A | value B ---------------------- 1 | abc | 3 1 | def | 5 1 | ghi | 1 2 | cba | 9 2 | fed | 4 I want the rows from within any ‘ID-group’ that has it’s minimum within that...
View ArticlePostgres Partition Table Trigger inserting duplicate records
I have a trigger applied on my database table. But when i insert data into it via hibernate jpa it creates duplicate rows in master table. Here is the trigger CREATE OR REPLACE FUNCTION...
View ArticleI want to start the Postgres database
I run this: $ postgres -D foobar It just hangs. There is no error message. I newly created this database with the initdb command. What should I do?
View ArticleTrigger function check if all NEW.* fields exist in another table
In PostgreSQL I need to code a trigger function that checks if all the fields in NEW.* exist in another table that has the exact same name as the table that fired the trigger but appended with “_hv”....
View ArticlePostgreSQL GUI Tools with Git repository integration [closed]
I’m currently evaluating PostgreSQL GUI tools that have following capabilities: Query Editor GIT Repository Integration for version control Change script generation for deployment between the GIT...
View ArticlePerfom SQL queries in Python and process the result
I query column names from a PostGIS table with following Python code: colnames = [] sql_getcolumns = "select column_name from information_schema.columns where table_name='shp2py';"...
View ArticleHow to model state change timeline
I’ve got an app where users can place orders for recurring delivery of a particular service. The orders table has columns service_id and state, where service_id links to the service the user has...
View Article