Re: [GENERAL] Why would log_lock_waits affect a query plan?

2017-07-19 Thread Evan Martin
On 19/07/2017 11:52 PM, Tom Lane wrote: Evan Martin writes: I have an application that imports a lot of data and the does some queries on it to build some caches in the database, all in one long transaction. One of those cache updates repeatedly calls a plpgsql function, which internally does

[GENERAL] Why would log_lock_waits affect a query plan?

2017-07-19 Thread Evan Martin
I have an application that imports a lot of data and the does some queries on it to build some caches in the database, all in one long transaction. One of those cache updates repeatedly calls a plpgsql function, which internally does some SQL queries. Sometimes this is much, much slower than us

Re: [GENERAL] Way to quickly detect if database tables/columns/etc. were modified?

2016-10-31 Thread Evan Martin
On 31/10/2016 8:26 PM, Melvin Davidson wrote: I have tried using an event trigger to detect table creation (ie: tg_event_audit_all ) however, that does not parse the schema_name and objid as does pg_event_trigger_dropped_objects(), so I am not sure that is a practical way to audit. Event trig

[GENERAL] Way to quickly detect if database tables/columns/etc. were modified?

2016-10-30 Thread Evan Martin
If I have a query that reads from system tables like pg_class, pg_namespace, pg_attribute, pg_type, etc. and I'd like to cache the results in my application is there any fast way to detect when any changes have been made to these system catalogs? I don't need to know exactly what has changed.

Re: [GENERAL] Workaround for bug #13148 (deferred EXCLUDE constraint violation)

2015-04-28 Thread Evan Martin
inside the transaction block doesn't prevent the constraint violation, either. On 28/04/2015 2:16 PM, John McKown wrote: On Mon, Apr 27, 2015 at 7:45 AM, Evan Martin mailto:postgre...@realityexists.net>>wrote: I submitted the following bug report through the web form a few d

[GENERAL] Workaround for bug #13148 (deferred EXCLUDE constraint violation)

2015-04-27 Thread Evan Martin
I submitted the following bug report through the web form a few days ago. It's causing problems in my application and I've been unable to find a way to get around it. If someone here, familiar with PostgreSQL internals, could suggest a workaround I'd really appreciate it! I have a deferred EX

[GENERAL] Detecting query timeouts properly

2014-09-21 Thread Evan Martin
Hello, I'm using PostgreSQL 9.2.8 via Npgsql 2.2.0. When a query times out it returns error 57014 with the message "canceling statement due to statement timeout". I use the message to detect the timeout and re-try in some cases. It seems a bit wrong to rely on the message, though - I presume

[GENERAL] Efficiently delete rows not referenced by a foreign key

2014-03-03 Thread Evan Martin
Hi All, I have a database schema where if row is deleted from one table the rows it references in another table should also be deleted, unless still referenced by something else. Eg. Table A has foreign key to table B. When I delete a row from A I also want to delete the referenced row in B,

Re: [GENERAL] Re: Drop all overloads of a function without knowing parameter types

2014-02-04 Thread Evan Martin
On 04/02/2014 19:56, David Johnston wrote: No, they cannot. If the arguments change you are dealing with an entirely new object. And often you end up keeping the old function around for backward-compatibility. Of course, I understand that it's a different object, technically, but from the user

Re: [GENERAL] Drop all overloads of a function without knowing parameter types

2014-02-04 Thread Evan Martin
In a nutshell: I think the difficulty of dropping functions is inconsistent with the difficulty of dropping other objects and I'd like to see this inconsistency fixed. So I don't agree with the suggestion of matching function names using a regex, since that's not supported for other types of o

Re: [GENERAL] Drop all overloads of a function without knowing parameter types

2014-02-03 Thread Evan Martin
ads of a given function name..." Regards, Evan On 03/02/2014 19:09, Tom Lane wrote: Evan Martin writes: Is there any easy way to drop a function (all overloads of it) without knowing the parameter types? Something along the lines of do $$ declare fname text; begin for fname in sel

[GENERAL] Drop all overloads of a function without knowing parameter types

2014-02-03 Thread Evan Martin
Hi All, Is there any easy way to drop a function (all overloads of it) without knowing the parameter types? If not, it would be good to see it added. When I change a function definition I just want to run the SQL script that defines it and have any existing function replaced. CREATE OR REPLA

[GENERAL] Danger of renaming an enum label?

2013-09-12 Thread Evan Martin
I'd like to rename one of the labels of an enum in PostgreSQL 9.2 This can easily be done by updating pg_enum, as described at http://tech.valgog.com/2010/08/alter-enum-in-postgresql.html but I'd like to understand: what is the danger of doing so? If, as the post says, the data only references

Re: [GENERAL] Spurious error messages from pg_restore

2013-09-05 Thread Evan Martin
though, and such pain points are unnecessary. Backups and restores should "just work". They do in MSSQL and I think they can in Postgres, too. Regards, Evan On 04.09.2013 23:26, David Johnston wrote: Evan Martin wrote When I use pg_restore with --clean to restore a PostgreSQL 9.2.

Re: [GENERAL] Spurious error messages from pg_restore

2013-09-05 Thread Evan Martin
Johnston wrote: Evan Martin wrote Also, even without --clean I get 3 errors: pg_restore: [archiver (db)] Error while PROCESSING TOC: pg_restore: [archiver (db)] Error from TOC entry 6755; 2618 4417788 RULE geometry_columns_delete em pg_restore: [archiver (db)] could not execute query: ERROR: rule

Re: [GENERAL] Spurious error messages from pg_restore

2013-09-04 Thread Evan Martin
ould want any existing function with the same signature to be overwritten. On 04.09.2013 18:20, Adrian Klaver wrote: On 09/04/2013 07:02 AM, Evan Martin wrote: Also, even without --clean I get 3 errors: pg_restore: [archiver (db)] Error while PROCESSING TOC: pg_restore: [archiver (db)] Erro

[GENERAL] Spurious error messages from pg_restore

2013-09-04 Thread Evan Martin
When I use pg_restore with --clean to restore a PostgreSQL 9.2.4database into a new, blank database it generates thousands of error messages like this: pg_restore: [archiver (db)] could not execute query: ERROR: schema "myschema" does not exist Command was: DROP INDEX myschema.some_index

Re: [GENERAL] Please make it easy to drop a database that is in use

2012-06-21 Thread Evan Martin
On 22/06/2012 12:07 AM, Tom Lane wrote: SELECT pg_terminate_backend(procpid) FROM pg_stat_activity WHERE datname = 'dropme'; ERROR: must be superuser to signal other server processes As far as that goes, there's a pending patch to reduce the privileges required to use pg_terminate_backend. I'm

Re: [GENERAL] Please make it easy to drop a database that is in use

2012-06-21 Thread Evan Martin
On 21/06/2012 10:20 PM, Sergey Konoplev wrote: On Thu, Jun 21, 2012 at 2:03 PM, Evan Martin wrote: 1) The workaround requires extra work for each developer (or at least each client application) using PostgreSQL, while a fix in PostgreSQL would solve this once and for all. It is not clean what

Re: [GENERAL] Please make it easy to drop a database that is in use

2012-06-21 Thread Evan Martin
privileges, which I don't think should be required to drop your own database. Regards, Evan On 20/06/2012 10:51 PM, Sergey Konoplev wrote: On Tue, Jun 19, 2012 at 1:40 PM, Evan Martin wrote: When I'm developing against a PostgreSQL database I often drop and re-create it and I often

[GENERAL] Please make it easy to drop a database that is in use

2012-06-19 Thread Evan Martin
Hi All, When I'm developing against a PostgreSQL database I often drop and re-create it and I often find that the drop fails, because it's "in use by other users". This is really annoying, especially when I know full well there are no other users - it's just me. I'm aware of the workaround:

Re: [GENERAL] Slow queries when functions are inlined

2012-05-16 Thread Evan Martin
DWithin? Just trying to understand this better so I know what to ask on the PostGIS list. Thanks, Evan On 17/05/2012 12:31 AM, Tom Lane wrote: Evan Martin writes: I've run into a weird query performance problem. I have a large, complex query which joins the results of several set-r

[GENERAL] Slow queries when functions are inlined

2012-05-15 Thread Evan Martin
I've run into a weird query performance problem. I have a large, complex query which joins the results of several set-returning functions with some tables and filters them by calling another function, which involves PostGIS calls (ST_DWithin). This used to run in about 10 seconds until I change

Re: [GENERAL] Why is RELEASE SAVEPOINT sometimes slow?

2012-05-13 Thread Evan Martin
I dug a bit further into this and found that the code was also creating and releasing a savepoint for each insert (and there were over 10,000 of them). When I removed that the delay at the end disappeared. Regards, Evan On 11/05/2012 8:26 PM, Simon Riggs wrote: On 11 May 2012 11:16, Evan

[GENERAL] Why is RELEASE SAVEPOINT sometimes slow?

2012-05-11 Thread Evan Martin
I'm running a bulk import application against PostgreSQL 9.1.3, which has several stages and each stage follows the same general pattern: BEGIN TRANSACTION DELETE (many rows) CREATE SAVEPOINT INSERT ... RELEASE SAVEPOINT CREATE SAVEPOINT INSERT INSERT ... half an hour of inserts later ... RELE

Re: [GENERAL] SQL functions not being inlined

2012-05-03 Thread Evan Martin
e which are inherent limitations and which are current implementation restrictions. I'm going to write this up as a blog post just for my own reference, but nobody else is going to find it there. I'd love to see it documented properly by someone who knows what they're talking about

Re: [GENERAL] SQL functions not being inlined

2012-05-03 Thread Evan Martin
I'm surprised more people don't run into it. Even better would be some query that checks whether a function is inlineable - maybe not perfectly, but it could detect a few of the reasons just from pg_proc, right? Regards, Evan On 2/05/2012 11:41 PM, Tom Lane wrote: Evan Martin writ

Re: [GENERAL] SQL functions not being inlined

2012-05-02 Thread Evan Martin
valid_time_end IS NULL) OR ('2012-04-01 00:00:00'::timestamp without time zone < (valid_time_end)::timestamp without time zone))) Any idea what's going on? It seems like the query optimizer randomly changes its mind about inlining it. Regards, Evan On 2/05/2012 3:34 PM, E

Re: [GENERAL] SQL functions not being inlined

2012-05-01 Thread Evan Martin
PostgreSQL - they're not inlined any more. I really don't know what to think! Regards, Evan On 2/05/2012 1:44 PM, Tom Lane wrote: Evan Martin writes: Some of my functions are running much slower than doing the same query "inline" and I'd like to know if there's

[GENERAL] SQL functions not being inlined

2012-05-01 Thread Evan Martin
Some of my functions are running much slower than doing the same query "inline" and I'd like to know if there's a way to fix that. I have a number of tables that store data valid at different times. For each logical entity there may be multiple rows, valid at different times (sometimes overlap

[GENERAL] Plans to fix table inheritance caveats

2011-10-17 Thread Evan Martin
Hi, Are there any plans to fix the caveats documented in section 5.8.1, particularly allowing rows in a derived table to satisfy a foreign key defined on a base table? I know it's on the TODO list ( http://wiki.postgresql.org/wiki/Todo#Inheritance ) - just wondering if anyone is actually work