Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eEgYR-0000gB-LQ for pgsql-hackers@arkaria.postgresql.org; Tue, 14 Nov 2017 19:07:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eEgYQ-0004Lu-Sy for pgsql-hackers@arkaria.postgresql.org; Tue, 14 Nov 2017 19:07:26 +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 1eEgYQ-0004Lk-KS for pgsql-hackers@lists.postgresql.org; Tue, 14 Nov 2017 19:07:26 +0000 Received: from mail-qt0-f177.google.com ([209.85.216.177]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eEgYN-0002XI-Cp for pgsql-hackers@postgresql.org; Tue, 14 Nov 2017 19:07:25 +0000 Received: by mail-qt0-f177.google.com with SMTP id n61so28055542qte.10 for ; Tue, 14 Nov 2017 11:07:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:subject:to:cc:references:from :organization:message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=Z1R2CrZfkcOMgDkk7q/SADUrWFb/Sfw2y7lXuBbng/Y=; b=exhEoQqK0LIgnFPs83DCVqTFa0eZ/I+bedkteS5r4UZGL+c5GqZozXD1ghnIYtyRxd tAokXKM3mGQ7VJwrZVFFnSGhFyWltrDTC+dm8eocG+4lZwF0fthRqYf6m6K2kN+9sZcB jVEQcDMRkNIGB3Z6RS3D5jzEJZhrEFx2GMB5EtCj/2w7SvCNjWa/ZQ2CHoiF7oDE+8tw N4TGLyJ1J7iv/zPSiD4wlc3poUItawO9nzmI1hfU50cxLAZHPimEmTjKzMMbkQm3KhiQ BixJr7V1Aa1+y4pCukwDV2jtvBZ8a39Pqo8bGnTjhFfP1c0D6F5Zp2XDRQFEwulD5sVs qAjQ== X-Gm-Message-State: AJaThX7P6Som+SsfDN9SKeJiu0lqGd8OXSU5e+wHkfzbEsvykb9SPXQO BkpPcZpPmR1r8Twc9Ez71WNp7g== X-Google-Smtp-Source: AGs4zMY7kHOwdU+hAnmfb6IOGtfCCGlSOrNcpEofn9gzKE+VkopglGjjbqLTWKiLHAENiFbq/bzQgA== X-Received: by 10.200.43.8 with SMTP id 8mr21539528qtu.193.1510686441851; Tue, 14 Nov 2017 11:07:21 -0800 (PST) Received: from localhost.localdomain (c-24-61-8-151.hsd1.ma.comcast.net. [24.61.8.151]) by smtp.gmail.com with ESMTPSA id b45sm13167754qta.89.2017.11.14.11.07.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Nov 2017 11:07:21 -0800 (PST) Reply-To: jesper.pedersen@redhat.com Subject: Re: [HACKERS] Proposal: Local indexes for partitioned table To: Alvaro Herrera Cc: Simon Riggs , Robert Haas , Pg Hackers , Maksim Milyutin References: <20171114174946.m7ihrns7jxzrsavz@alvherre.pgsql> From: Jesper Pedersen Organization: Red Hat Message-ID: <3d57d8ad-e76d-f0cf-0c42-d1202c643dba@redhat.com> Date: Tue, 14 Nov 2017 14:07:20 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20171114174946.m7ihrns7jxzrsavz@alvherre.pgsql> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 11/14/2017 12:49 PM, Alvaro Herrera wrote: >> Thanks, pushed. > > Here's the remaining bits, rebased. > First of all, thanks for working on this. I have been looking at the "CREATE INDEX ... ONLY" syntax, and I think it could cause some confusion due to the "Note" described in create_index.sgml. An alternative, maybe crazy, could be to treat a partitioned index as one; e.g. all operations are on the definition. That way ONLY, ATTACH and DETACH could be eliminated. Once a partition is detached any partitioned indexes would be marked as a normal index, and a partition could only be attached if it had indexes satisfying all partition index definitions. Bloat could be handled by swapping the index as suggested by David [1]. It would be less flexible, but people always have the option to define indexes directly on the partitions. Some comments. 0004's alter_index.sgml are missing the "PARTITION" keyword for both the ATTACH and DETACH commands. A small thing, for -- test.sql -- CREATE TABLE test (a integer NOT NULL) PARTITION BY HASH(a); CREATE TABLE test_p00 PARTITION OF test FOR VALUES WITH (MODULUS 2, REMAINDER 0); CREATE TABLE test_p01 PARTITION OF test FOR VALUES WITH (MODULUS 2, REMAINDER 1); CREATE INDEX idx_test_a ON test (a); -- test.sql -- I would expect that the index names were 'test_p00_idx_test_a' and 'test_p01_idx_test_a'. psql completion for "CREATE INDEX blah ON tes" only lists the child tables. Completion for the ALTER INDEX commands is missing. [1] https://www.postgresql.org/message-id/CAKJS1f_Wf%3DM06o8iQi72SxN%2BZpLV4c0CwYoN5xYVY4aWWX-jBQ%40mail.gmail.com Best regards, Jesper