Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e2TC4-0003Dc-Ah for pgsql-performance@arkaria.postgresql.org; Thu, 12 Oct 2017 02:25:52 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1e2TC3-00063o-Nk for pgsql-performance@arkaria.postgresql.org; Thu, 12 Oct 2017 02:25:51 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1e2TC3-00063d-2R for pgsql-performance@postgresql.org; Thu, 12 Oct 2017 02:25:51 +0000 Received: from mail-lf0-x22b.google.com ([2a00:1450:4010:c07::22b]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1e2TC0-00060z-5P for pgsql-performance@postgresql.org; Thu, 12 Oct 2017 02:25:49 +0000 Received: by mail-lf0-x22b.google.com with SMTP id l23so4346502lfk.10 for ; Wed, 11 Oct 2017 19:25:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=y+bVR8KqbAfdt7XPFagQ6hgPykcDSYkr76gQoucKEJk=; b=Dgj36pNP9ACXx3F5jYYCmWutn2HE0zZbLPaNAKRLPrQw6hr5B9HanF0uNpxI10Od+F 9uvYFLwHuCS0lxhnXiq855r/eRZc02UNlbgD10eRZeXi8Rlqyqzn9AFyB+GY21pD5mtV FJprzz3psCXEGTECeTC5o8JOqil2i1s+S/hZZJXHhwhx1WODXv2yA99GHRCg/84U63y4 ukkxmGPLE4mRWm2bmCruElo1O6kc0RcQe6SOyasxPcKiV+l6ovLeJAZrYW2hUageQKuq m8msN97m779+U8ENR3P+jGt5joB3MYP7NI8QOkuP4RZC0erisYfqqut1YSe2+riSYaYt VCEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=y+bVR8KqbAfdt7XPFagQ6hgPykcDSYkr76gQoucKEJk=; b=Phtu/p9cjlZbDIqc/a5z1xUvy8z9TetjFpjN5sVH5qmPZAeYmbZs0bPiZ+RDj6WhVY Mjrse+vDprIpeu42eFqHRE9LS1dtTo7SalnccSGg6BN1og8E12wHtr3Xokzlr09mJFBL bwWwScwm/DhyhUOfOgAzWSB3Ph743VVPVz8UT2w6hnUfMhmfHmceEwXNjrQ9Ed+tiZu9 IB19aYtJSDg6bGScPngVXVq2p2ahIHsonsjqUTTpII63wQhiXvJvkO+RfFz7KsR5p2P8 qV0HvIvVpsAiej7TMZ4TzViawswVW9AwPg5UzuxHtolZIM/GDnuIYcZyZFol/q/BVRq4 Jn9g== X-Gm-Message-State: AMCzsaWUdt+ZFTq4RJ5y3ZYcoq81PuuDONYCpOr7Tz+x+xxAfdHvLDyw BN21Lf2W6q5nF6py/Oaxe5goHmz/dFEy7fd9G08= X-Google-Smtp-Source: AOwi7QArLZo6mAqZUkZQl341EQckANA5htUOv/62N9N5aI52ZoNbWr5AZEEkLNHA1INdA3fm55/iCgxeloLpLX6/FgY= X-Received: by 10.46.7.66 with SMTP id i2mr351435ljd.135.1507775145400; Wed, 11 Oct 2017 19:25:45 -0700 (PDT) MIME-Version: 1.0 Received: by 10.25.195.12 with HTTP; Wed, 11 Oct 2017 19:25:44 -0700 (PDT) In-Reply-To: References: <1507729579.2627.13.camel@cybertec.at> From: Scott Marlowe Date: Wed, 11 Oct 2017 20:25:44 -0600 Message-ID: Subject: Re: blocking index creation To: Neto pr Cc: Tomas Vondra , Laurenz Albe , postgres performance list Content-Type: text/plain; charset="UTF-8" List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Try the queries here to check locks: https://wiki.postgresql.org/wiki/Lock_Monitoring On Wed, Oct 11, 2017 at 7:35 PM, Neto pr wrote: > Dear, > With alternative, I tested the creation using concurrency > (CREATE INDEX CONCURRENCY NAME_IDX ON TABLE USING HASH (COLUMN); > > from what I saw the index already appeared in the query result, because > before this, the index did not even appear in the result, only the Lineitem > table: > > SELECT > L.mode, c.relname, locktype, l.GRANTED, l.transactionid, > virtualtransaction > FROM pg_locks l, pg_class c > where c.oid = l.relation > > screen result after concurrency: https://i.stack.imgur.com/htzIY.jpg > > Now, I'm waiting to finish creating the index. > > 2017-10-11 19:54 GMT-03:00 Neto pr : >> >> Hello all, >> I ran the query on PG_STAT_ACTIVITY table (Select * From >> pg_stat_activity), see the complete result in this worksheet of the link >> below. >> >> >> https://sites.google.com/site/goissbr/img/Resultado_pg_stat_activity-create_index.xls >> >> The CREATE INDEX command line is identified with the orange background. >> At this point 18 hours have passed and the creation of a single index has >> not yet been completed. >> I have verified that the command is Active status, but I do not know if >> it's waiting for anything, can you help me analyze the attached output. >> >> Regards >> Neto >> >> 2017-10-11 18:08 GMT-03:00 Tomas Vondra : >>> >>> >>> >>> On 10/11/2017 04:11 PM, Neto pr wrote: >>> > >>> > 2017-10-11 10:46 GMT-03:00 Laurenz Albe >> > >: >>> > >>> > Neto pr wrote: >>> > > When creating index on table of approximately 10GB of data, the >>> > DBMS hangs (I think), >>> > > because even after waiting 10 hours there was no return of the >>> > command. >>> > > It happened by creating Hash indexes and B + tree indexes. >>> > > However, for some columns, it was successfully (L_RETURNFLAG, >>> > L_PARTKEY). >>> > >>> > > If someone has a hint how to speed up index creation so that it >>> > completes successfully. >>> > >>> > Look if CREATE INDEX is running or waiting for a lock (check the >>> > "pg_locks" table, see if the backend consumes CPU time). >>> > >>> > >>> > In this moment now, there is an index being created in the Lineitem >>> > table (+ - 10 Gb), and apparently it is locked, since it started 7 >>> > hours >>> > ago. >>> > I've looked at the pg_locks table and look at the result, it's with >>> > "ShareLock" lock mode. >>> > Is this blocking correct? or should it be another type? >>> > >>> >>> Yes, CREATE INDEX acquire SHARE lock, see >>> >>> https://www.postgresql.org/docs/9.1/static/explicit-locking.html >>> >>> > Before creating the index, should I set the type of transaction lock? >>> > What? >>> >>> Eeee? Not sure I understand. The command acquires all necessary locks >>> automatically. >>> >>> > >>> > ------------------------------------------------------------------------------------------- >>> > SELECT >>> > L.mode, c.relname, locktype, l.GRANTED, l.transactionid, >>> > virtualtransaction >>> > FROM pg_locks l, pg_class c >>> > where c.oid = l.relation >>> > >>> > -------------- RESULT >>> > -------------------------------------------------------------- >>> > AccessShareLock pg_class_tblspc_relfilenode_index relation >>> > TRUE >>> > (null) 3/71 >>> > AccessShareLock pg_class_relname_nsp_index relation >>> > TRUE (null) 3/71 >>> > AccessShareLock pg_class_oid_index relation TRUE >>> > (null) 3/71 >>> > AccessShareLock pg_class relation TRUE (null) >>> > 3/71 >>> > AccessShareLock pg_locks relation TRUE (null) >>> > 3/71 >>> > ShareLock lineitem relation TRUE (null) 21/3769 >>> > >>> > >>> >>> Well, we see something is holding a SHARE lock on the "lineitem" table, >>> but we don't really know what the session is doing. >>> >>> There's a PID in the pg_locks table, you can use it to lookup the >>> session in pg_stat_activity which includes the query (and also "state" >>> column that will tell you if it's active or waiting for a lock. >>> >>> regards >>> >>> -- >>> Tomas Vondra http://www.2ndQuadrant.com >>> PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services >> >> > -- To understand recursion, one must first understand recursion. -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance