Skip site navigation (1) Skip section navigation (2)

Re: update functions locking tables

From: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>
To: Clodoaldo Pinto <clodoaldo(dot)pinto(at)gmail(dot)com>
Cc: Michael Fuhr <mike(at)fuhr(dot)org>,"pgsql-general postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: update functions locking tables
Date: 2005-08-30 23:47:04
Message-ID: 20050830234704.GF77007@pervasive.com (view raw or flat)
Thread:
Lists: pgsql-general
On Tue, Aug 30, 2005 at 08:13:15AM -0300, Clodoaldo Pinto wrote:
> 2005/8/29, Michael Fuhr <mike(at)fuhr(dot)org>:
> > 
> > In general, writers shouldn't block readers.  Have you examined
> > pg_locks?  Do you know exactly what the blocked queries are, or can
> > you find out from pg_stat_activity (stats_command_string must be
> > enabled)?  Are you doing any explicit locking (LOCK statement)?
> > 
> 
> This is one of the blocked queries:
> select count (*) from times_producao where pontos_0 - pontos_7 > 0;

FWIW, that where clause might be more efficient as
WHERE pontos_0 > pontos_7. Some databases would be able to use indexes
to answer that (not sure if PostgreSQL could), plus it removes an
operator. It also seems to be cleaner code to me. :)
-- 
Jim C. Nasby, Sr. Engineering Consultant      jnasby(at)pervasive(dot)com
Pervasive Software        http://pervasive.com        512-569-9461

In response to

Responses

pgsql-general by date

Next:From: Clodoaldo PintoDate: 2005-08-31 01:16:58
Subject: Re: update functions locking tables
Previous:From: Ben-Nes YonatanDate: 2005-08-30 23:27:30
Subject: Re: Planner create a slow plan without an available index

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group