Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id A97551335B36 for ; Wed, 1 Dec 2010 10:35:14 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 53357-09 for ; Wed, 1 Dec 2010 14:35:06 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id B8A391336B42 for ; Wed, 1 Dec 2010 10:35:06 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id oB1EZ6iH015223; Wed, 1 Dec 2010 09:35:06 -0500 (EST) To: bakkiya cc: pgsql-admin@postgresql.org Subject: Re: Postgres problem with partition queries In-reply-to: <1291182677403-3287234.post@n5.nabble.com> References: <1291182677403-3287234.post@n5.nabble.com> Comments: In-reply-to bakkiya message dated "Tue, 30 Nov 2010 21:51:17 -0800" Date: Wed, 01 Dec 2010 09:35:06 -0500 Message-ID: <15222.1291214106@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201012/2 X-Sequence-Number: 36231 bakkiya writes: > We are having a partition table and we are querying some rows in the > partition. > select * from events where > events.evt_time >= '2010-11-29 00:00:00' > AND events.evt_time <= '2010-11-30 23:59:59' > While this query is in running state, I am issuing a drop statement on a > partition of this table. > [ and it blocks ] This is hardly surprising. A query on the inheritance tree has to take AccessShare lock on every member table, because it has to inspect each table to determine whether it should scan it. So it's going to conflict with the exclusive lock needed to drop one of the tables. That means first that the DROP gets blocked by a pre-existing query, and second that the waiting DROP also blocks other queries of the same kind. regards, tom lane