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

Image may be NSFW.
Clik here to view.

postgreSQL FK on delete set null not working

I want to set FK constraint on delete to null but it is not working. In table transactionauditlogentry I have altered the FK constraints for Packet and Credit table to on delete set null. If I delete a...

View Article


How to optimize view with group by

Have view with query : SELECT min(lbl.id) AS id, lb.order_id, lb.par_id, lbl.lb_id, lb.categ_id, lbl.mt_id, lbl.uom_id, lbl.tracking_id, sum(lbl.orig_qty) AS orig_qty, max(lbl.qty) AS qty,...

View Article


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

Trigger to create symmetrical rows

I’ve got a table that describes some relation between two items. The items are referenced by ID. I’d like to create a trigger, so whenever you create a row (a,b), a symmetrical row (b,a) is created....

View Article

Foreign key violations detected upon UPDATE on another column

I have a table country that is referenced by many tables like so: db=# d client Table "public.client" Column | Type | Modifiers --------------------------+-----------------------------+----------- id |...

View Article


Image may be NSFW.
Clik here to view.

How to make sure vacuum is happening in postgres sql db

I have created a table with two columns and created index for the first column. Then inserted 2 million data using generate series function for first column (2nd column is having null). And executed...

View Article

PostgreSQL Bloat Warning: Vaccuum does not help

We use check_postgres to monitor our DB. We get this warning: POSTGRES_BLOAT WARNING: DB "foo" (db foo) index foo_text_index_id_uniq rows:? pages:485435 shouldbe:330673 (1.5X) wasted bytes:1267810304...

View Article

Syntax error on REVOKE? [closed]

I’m setting up a database for a new application and I’m trying to secure the passwords. I used http://www.p2d2.cz/files/hagander-secure-passwords.pdf as a reference to generate the following SQL: -- --...

View Article


Use large set of data in multiple databases

I have been thinking about this a lot but somehow can’t figure out how to deal with it in an efficient matter. Say you have a large set “X” of data that consists of multiple tables. For the sake of...

View Article


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

Fatal error when not numeric value – PostgreSQL 9.2 [closed]

Below is an example of the auto-generated update query, with client-supplied keys (_iid). There’s a fatal error when _iid is not numeric. However; this should accept any value. I believe that’s what...

View Article

How to get max sequence of rows? [duplicate]

This question already has an answer here: Select longest continuous sequence 2 answers

View Article

“using stale statistics instead of current ones because stats collector is...

My postgresql 9.5 logs shows every minute the message: using stale statistics instead of current ones because stats collector is not responding Except a post on serverfault which is not helpfull and...

View Article


How to set Postgresql database to see date as “MDY” permanently

How can I set my database to see the ‘date’ as “MDY” without running: SET datestyle = "ISO, MDY"; every-time I’m trying to access it? I’m using Postgresql version 9.1, Ubuntu 12.04. My system locale,...

View Article

Reducing the time when retrieving all records from large databases

I have to retrieve most of the records from large table, I’m talking about approximately 3 millions rows. I’m even using this site as a guide for tuning the database. It is not enough, it takes an...

View Article


When can I clean up archived WAL files?

I need some help understanding the how archived WAL files are used and when I can clean them up. Currently we have a master database replicating to a slave, but every so often our master database...

View Article

Specifying a username while running initdb causes error in log on start of...

I have been forced to use a different default username for PostgreSQL. Before you ask: no, this is not something I can avoid. It’s dumb, I know. Let’s move on: In order to do this in an existing Cent...

View Article


Passing ROWTYPE parameter to EXECUTE

I am developing a function in Postgres which aims to recover for each record of a query the value of a result of a check contained in a set of functions. Only one of these functions will return the...

View Article

PostgreSQL not using index during count(*)

I have a COUNT(*) query in PostgreSQL that runs often, and looks like: SELECT COUNT(*) FROM customer WHERE source_id IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); This query takes between...

View Article

Optimize performance for query with CTE using a multicolumn index

I’ve got this slow query: WITH flks AS (SELECT id FROM public.ja_feedlog WHERE gtime BETWEEN EXTRACT(EPOCH FROM TIMESTAMP '2016-01-24')::BIGINT AND EXTRACT(EPOCH FROM TIMESTAMP '2016-03-25')::BIGINT...

View Article
Browsing all 1138 articles
Browse latest View live