From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 75B904696C3 for ; Tue, 7 Apr 2020 00:42:41 +0300 (MSK) References: <81e5cba334c04467e28948a491bd95d38f0d08ae.1585824116.git.imeevma@gmail.com> From: Vladislav Shpilevoy Message-ID: <81e5efe8-1627-6294-73bf-77db32e68e5a@tarantool.org> Date: Mon, 6 Apr 2020 23:42:39 +0200 MIME-Version: 1.0 In-Reply-To: <81e5cba334c04467e28948a491bd95d38f0d08ae.1585824116.git.imeevma@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Tarantool-patches] [PATCH v2 1/1] sql: do not change order of inserted values List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: imeevma@tarantool.org, tsafin@tarantool.org, tarantool-patches@dev.tarantool.org Hi! Thanks for the patch! See 2 questions below. > diff --git a/src/box/sql.c b/src/box/sql.c > index 27089bd..7c1eba2 100644 > --- a/src/box/sql.c > +++ b/src/box/sql.c > @@ -324,10 +324,17 @@ struct space * > sql_ephemeral_space_create(uint32_t field_count, struct sql_key_info *key_info) > { > struct key_def *def = NULL; > + uint32_t part_count = field_count; > if (key_info != NULL) { > def = sql_key_info_to_key_def(key_info); > if (def == NULL) > return NULL; > + /* > + * In case is_pk_rowid is true we can use rowid > + * as the only part of the key. > + */ > + if (key_info->is_pk_rowid) > + part_count = 1; 1. On one hand this can really speed up ephemeral space comparators, because we have special templates for single indexed unsigned field if it is in 1, 2, or 3 column. On the other hand this won't help, because rowid is the last column somewhy. And these fast comparators won't help. Can we make rowid first column? > } > > struct region *region = &fiber()->gc; > @@ -364,17 +371,20 @@ sql_ephemeral_space_create(uint32_t field_count, struct sql_key_info *key_info) > } > } > > - for (uint32_t i = 0; i < field_count; ++i) { > + for (uint32_t i = 0; i < part_count; ++i) { > struct key_part_def *part = &parts[i]; > - part->fieldno = i; > + uint32_t j = i; > + if (key_info != NULL && key_info->is_pk_rowid) > + j = field_count - 1; 2. Does it make sense to use part count > 1, if we have rowid? It is unique anyway.