Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: Nikita Pettik <korablev@tarantool.org>, tarantool-patches@freelists.org
Subject: [tarantool-patches] Re: [PATCH 1/4] sql: optimize compilation of SELECT COUNT(*)
Date: Tue, 24 Apr 2018 15:51:46 +0300	[thread overview]
Message-ID: <408fa156-ccbd-5743-8b31-9daa80c47b26@tarantool.org> (raw)
In-Reply-To: <45c716b50ab9dd7405c1d8c20b86abbd639b5f25.1524515002.git.korablev@tarantool.org>

See my 1 comment below. And please, rebase on the latest 2.0 - maybe some parts of your
patchset will become simpler.

On 23/04/2018 23:29, Nikita Pettik wrote:
> Originally, SQLite chooses the best index to perform COUNT operation.
> In Tarantool there is no any considerable difference between them,
> so lets don't spend time on this routine and choose always primary index,
> in case of simple query 'SELECT COUNT(*) FROM <tab>'.
> Also, patch contains codestyle fixes.
> ---
>   src/box/sql/select.c      | 172 ++++++++++++++++++----------------------------
>   src/box/sql/vdbe.c        |   2 -
>   test/sql-tap/eqp.test.lua |   2 +-
>   3 files changed, 68 insertions(+), 108 deletions(-)
> 
> diff --git a/src/box/sql/select.c b/src/box/sql/select.c
> index d97e466b5..0df8a71d4 100644
> --- a/src/box/sql/select.c
> +++ b/src/box/sql/select.c
> @@ -5294,25 +5296,23 @@ updateAccumulator(Parse * pParse, AggInfo * pAggInfo)
>   	}
>   }
>   
> -/*
> - * Add a single OP_Explain instruction to the VDBE to explain a simple
> - * count(*) query ("SELECT count(*) FROM pTab").
> +/**
> + * Add a single OP_Explain instruction to the VDBE to explain
> + * a simple count(*) query ("SELECT count(*) FROM <tab>").
> + *
> + * @param parse_context Current parsing context.
> + * @param table_name Name of table being queried.
>    */
>   #ifndef SQLITE_OMIT_EXPLAIN>   static void
> -explainSimpleCount(Parse * pParse,	/* Parse context */
> -		   Table * pTab,	/* Table being queried */
> -		   Index * pIdx)	/* Index used to optimize scan, or NULL */
> +explain_simple_count(struct Parse *parse_context, const char *table_name)
>   {
> -	if (pParse->explain == 2) {
> -		int bCover = (pIdx != 0 && !IsPrimaryKeyIndex(pIdx));
> -		char *zEqp = sqlite3MPrintf(pParse->db, "SCAN TABLE %s%s%s",

1. In Tarantool 'memtx' count() is not a scan - it is O(1) operation, that simply
gets current size of the primary index B+ tree. Maybe worth show it in the
explanation.

  reply	other threads:[~2018-04-24 12:51 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-23 20:29 [tarantool-patches] [PATCH 0/4] Move original SQLite's statistics to server Nikita Pettik
2018-04-23 20:29 ` [tarantool-patches] [PATCH 1/4] sql: optimize compilation of SELECT COUNT(*) Nikita Pettik
2018-04-24 12:51   ` Vladislav Shpilevoy [this message]
2018-05-11 17:29     ` [tarantool-patches] " n.pettik
2018-04-23 20:29 ` [tarantool-patches] [PATCH 2/4] sql: add average tuple size calculation Nikita Pettik
2018-04-24 12:51   ` [tarantool-patches] " Vladislav Shpilevoy
2018-05-11 17:29     ` n.pettik
2018-04-23 20:29 ` [tarantool-patches] [PATCH 3/4] sql: refactor usages of table's tuple count Nikita Pettik
2018-04-24 12:51   ` [tarantool-patches] " Vladislav Shpilevoy
2018-05-11 17:29     ` n.pettik
2018-04-23 20:29 ` [tarantool-patches] [PATCH 4/4] sql: move SQL statistics to server Nikita Pettik
2018-04-24 12:51   ` [tarantool-patches] " Vladislav Shpilevoy
2018-05-11 17:29     ` n.pettik
2018-05-11 22:00       ` Vladislav Shpilevoy
2018-05-14 11:52         ` n.pettik
2018-05-14 12:54           ` Vladislav Shpilevoy
2018-05-14 13:55             ` n.pettik
2018-05-14 14:12 ` [tarantool-patches] Re: [PATCH 0/4] Move original SQLite's " Vladislav Shpilevoy
2018-05-15 13:42   ` Kirill Yukhin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=408fa156-ccbd-5743-8b31-9daa80c47b26@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=korablev@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH 1/4] sql: optimize compilation of SELECT COUNT(*)' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox