Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r6SY0-000yDU-Pu for pgsql-hackers@arkaria.postgresql.org; Fri, 24 Nov 2023 09:32:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1r6SXy-009HkX-Ku for pgsql-hackers@arkaria.postgresql.org; Fri, 24 Nov 2023 09:32:26 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r6SXy-009HkM-Az for pgsql-hackers@lists.postgresql.org; Fri, 24 Nov 2023 09:32:26 +0000 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1r6SXv-0077Pc-Mw for pgsql-hackers@postgresql.org; Fri, 24 Nov 2023 09:32:25 +0000 Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-2856437b584so1166581a91.3 for ; Fri, 24 Nov 2023 01:32:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700818343; x=1701423143; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=3GC0LTTqKvbDCpfqLIdCL3yAJMroQ9Wfp7z6PJ/PEn8=; b=BBD29berpyKQ4r1/RwzU8MIig0ZBBJHmE6sxVo9egn9S8yc86tKnF7d+slstoupEKy zlyG3z9moh2IVui1aC8f7R9/BLiNTDOQVSisVKEhW/bdkT+TbPZHxgucjg5l+LbmMEia M7B2/cz4WSujMgwDor8iRyN93Fw5Yma/qbNXsKlQSEbx0n8HszHNjgbpdSn4ejI0QGBM WyLSxOByDyUqJwoWeDVSimnS+PN7HiETwOaqeJ7zIcU5OJ/raZ8IbtYA5Kv4wLvwDcIN 1tfzPm2E2J8J1VIz2SpnwMF10XXm+dZxWmfso0SxMv9bLr2vd4s4nublyYiTbE/1mxeF iQew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700818343; x=1701423143; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3GC0LTTqKvbDCpfqLIdCL3yAJMroQ9Wfp7z6PJ/PEn8=; b=OOjK9grZ1SlN7sDvoJFbbHp5lAVei4Q7VAweQnaCEty5zm4/C3VtNn/JC67QgN6xxG yfR/HqF7JJpag4YRkAYdAZEeBKem0rCeyZoZ9s7zqvd9zSNWwWqs21XV7NpdZhmqJAC7 43u0FpWEX55rSPyVb9f0UVngm/MOjLq1dlDl2M8TX+OSI9LzcdKrO7UtkvH8i4yvVQ3y zgDK1Xnj3BJ/v5RlLHcLIFYpTt4nlY9bgZnIjtAyYA4zhAMFBXuK6l7WOies52IQbadE CpRBar9onK1+YKsQ3WZjxK9dDgu4i+h/4dENZd+GmLei8BwTmgz3lv07rnGjAfu4Yhvc M/Fg== X-Gm-Message-State: AOJu0YyRPGaz2XnbYmMigynq/8WcXc0N1XaejnEMdXic/R4/hag/y20K BLnDnUffwsT6jDvVkcLfeIoUsYOf6KRi3Huonk0= X-Google-Smtp-Source: AGHT+IFwRpIhYXv1zktwpggkTk0lERr4YeWNG8ieUvc86KgKfBjKicGBxcQ6ZW/95IfJcW0JdBDpNPeJqW1BPtIndCU= X-Received: by 2002:a17:90b:1b52:b0:285:8127:7dab with SMTP id nv18-20020a17090b1b5200b0028581277dabmr1899144pjb.12.1700818342624; Fri, 24 Nov 2023 01:32:22 -0800 (PST) MIME-Version: 1.0 References: <202309281104.kmkr4v34ny2t@alvherre.pgsql> <20231006214856.yie5dedhzrcb3qxx@alap3.anarazel.de> <20231115171119.svvyzevtfvsqkxpx@awork3.anarazel.de> <20231122193848.vnhi4snatjdgq7uk@awork3.anarazel.de> In-Reply-To: <20231122193848.vnhi4snatjdgq7uk@awork3.anarazel.de> From: Amit Langote Date: Fri, 24 Nov 2023 18:32:06 +0900 Message-ID: Subject: Re: remaining sql/json patches To: Andres Freund Cc: Alvaro Herrera , Andrew Dunstan , jian he , Erik Rijkers , PostgreSQL-development Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Nov 23, 2023 at 4:38=E2=80=AFAM Andres Freund = wrote: > On 2023-11-21 12:52:35 +0900, Amit Langote wrote: > > version gram.o text bytes %change gram.c bytes %change > > > > 9.6 534010 - 2108984 - > > 10 582554 9.09 2258313 7.08 > > 11 584596 0.35 2313475 2.44 > > 12 590957 1.08 2341564 1.21 > > 13 590381 -0.09 2357327 0.67 > > 14 600707 1.74 2428841 3.03 > > 15 633180 5.40 2495364 2.73 > > 16 653464 3.20 2575269 3.20 > > 17-sqljson 672800 2.95 2709422 3.97 > > > > So if we put SQL/JSON (including JSON_TABLE()) into 17, we end up with = a gram.o 2.95% larger than v16, which granted is a somewhat larger bump, th= ough also smaller than with some of recent releases. > > I think it's ok to increase the size if it's necessary increases - but I = also > think we've been a bit careless at times, and that that has made the pars= er > slower. There's probably also some "infrastructure" work we could do com= bat > some of the growth too. > > I know I triggered the use of the .c bytes and text size, but it'd probab= ly > more sensible to look at the size of the important tables generated by bi= son. > I think the most relevant defines are: > > #define YYLAST 117115 > #define YYNTOKENS 521 > #define YYNNTS 707 > #define YYNRULES 3300 > #define YYNSTATES 6255 > #define YYMAXUTOK 758 > > > I think a lot of the reason we end up with such a big "state transition" = space > is that a single addition to e.g. col_name_keyword or unreserved_keyword > increases the state space substantially, because it adds new transitions = to so > many places. We're in quadratic territory, I think. We might be able to = do > some lexer hackery to avoid that, but not sure. One thing I noticed when looking at the raw parsing times across versions is that they improved a bit around v12 and then some in v13: 9.0 0.000060 s 9.6 0.000061 s 10 0.000061 s 11 0.000063 s 12 0.000055 s 13 0.000054 s 15 0.000057 s 16 0.000059 s I think they might be due to the following commits in v12 and v13 resp.: commit c64d0cd5ce24a344798534f1bc5827a9199b7a6e Author: Tom Lane Date: Wed Jan 9 19:47:38 2019 -0500 Use perfect hashing, instead of binary search, for keyword lookup. ... Discussion: https://postgr.es/m/20190103163340.GA15803@britannica.bec.d= e commit 7f380c59f800f7e0fb49f45a6ff7787256851a59 Author: Tom Lane Date: Mon Jan 13 15:04:31 2020 -0500 Reduce size of backend scanner's tables. ... Discussion: https://postgr.es/m/CACPNZCvaoa3EgVWm5yZhcSTX6RAtaLgniCPcBVOCwm8h3xpWkw@mai= l.gmail.com I haven't read the whole discussions there to see if the target(s) included the metrics you've mentioned though, either directly or indirectly. --=20 Thanks, Amit Langote EDB: http://www.enterprisedb.com