Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jxSjq-00042J-LO for pgsql-bugs@arkaria.postgresql.org; Mon, 20 Jul 2020 10:09:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jxSjo-00074f-Vj for pgsql-bugs@arkaria.postgresql.org; Mon, 20 Jul 2020 10:09:36 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jxEt8-0001T4-Ma for pgsql-bugs@lists.postgresql.org; Sun, 19 Jul 2020 19:22:18 +0000 Received: from mailout05.t-online.de ([194.25.134.82]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jxEt5-0005tB-Go for pgsql-bugs@lists.postgresql.org; Sun, 19 Jul 2020 19:22:17 +0000 Received: from fwd35.aul.t-online.de (fwd35.aul.t-online.de [172.20.27.145]) by mailout05.t-online.de (Postfix) with SMTP id C0016421863A for ; Sun, 19 Jul 2020 21:22:11 +0200 (CEST) Received: from [IPv6:::ffff:192.168.2.21] (SrUAcaZBoheW-nTSJardtwqSqKJD5MnuWzcdrqFRVaxTKdjwaOQK-Lxh1rCQjQeQW8@[92.117.255.59]) by fwd35.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1jxEsu-0bGx160; Sun, 19 Jul 2020 21:22:04 +0200 MIME-Version: 1.0 To: "pgsql-bugs@lists.postgresql.org" From: =?utf-8?Q?Tobias_V=C3=B6lk?= Subject: Improvement for query planner? (no, not about count(*) again ;-)) Date: Sun, 19 Jul 2020 21:22:03 +0200 Importance: normal X-Priority: 3 Content-Type: multipart/alternative; boundary="_23E75512-C156-46F4-9330-C7A03079D160_" X-Antivirus: Avast (VPS 200719-4, 19/07/2020), Outbound message X-Antivirus-Status: Clean Message-ID: <1jxEsu-0bGx160@fwd35.t-online.de> X-ID: SrUAcaZBoheW-nTSJardtwqSqKJD5MnuWzcdrqFRVaxTKdjwaOQK-Lxh1rCQjQeQW8 X-TOI-EXPURGATEID: 150726::1595186524-0000E07B-AC0D7E02/0/0 CLEAN NORMAL X-TOI-MSGID: 5ffd90e9-22d0-4cc1-a7f2-aaeee2aa1d8d List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --_23E75512-C156-46F4-9330-C7A03079D160_ Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Hello Postgres-Community, I=E2=80=99ve got a table games(name1 text, name2 text) with 1.3x10^9 rows c= onsisting of two two text columns for the names of players who=E2=80=99ve p= layed a game, duplicate rows are possible, there=E2=80=99s no primary key s= ince this table was just intended as a temporary storage for my data until = further processing. The length of a name is usually not more than 20 characters, shorter most o= f the time. I=E2=80=99ve asked postgres to make an unlogged newtable(name text primary = key) consisting of the unqiue names and executed: Insert into newtable(name) select name1 from games on conflict do nothing; (and later on intended to do the same for the second column) However after hours it still wasn=E2=80=99t done, used only 1 cpu core to t= he max and read with 5 MB/s from my fast SSD. So I stopped it. I=E2=80=99ve also tried inserting (select name1 from games union select nam= e2 from games) but it always wanted to do it using sorting. But either the sorting or the preperations for the sorting were again only = done using 1 core to the max and reading with 5 MB/s. Couldn=E2=80=99t find a fast query for my problem. So I wrote a java-program which read the whole table at a fetchsize of abou= t 4 million and inserted the names into a HashSet. And surprisingly after only a few minutes the program was already 25% done = o.O My question is, why isn=E2=80=99t postgres nearly this fast? Why doesn=E2= =80=99t it just create a HashSet in RAM and read full speed from the disk? I even created a hash index but it kept using it=E2=80=99s primary key b-tr= ee and then I read that hash indices somehow don=E2=80=99t support checking= for uniqueness. Best regards, Tobi -- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus --_23E75512-C156-46F4-9330-C7A03079D160_ Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="utf-8"

Hello Postgres-Community,

 

 

I=E2=80=99ve got a table games(name1 text, name2 tex= t) with 1.3x10^9 rows consisting of two two text columns for the names of p= layers who=E2=80=99ve played a game, duplicate rows are possible, there=E2= =80=99s no primary key since this table was just intended as a temporary st= orage for my data until further processing.

&n= bsp;

The length of a name is usually not more= than 20 characters, shorter most of the time.

I=E2= =80=99ve asked postgres to make an unlogged newtable(name text primary key)= consisting of the unqiue names and executed:

=  

Insert into newtable(name) select name= 1 from games on conflict do nothing;

(and later on = intended to do the same for the second column)

 

However after hours it still wasn=E2= =80=99t done, used only 1 cpu core to the max and read with 5 MB/s from my = fast SSD.

So I stopped it.

= I=E2=80=99ve also tried inserting (select name1 from games union select nam= e2 from games) but it always wanted to do it using sorting.

But either the sorting or the preperations for the sorting were ag= ain only done using 1 core to the max and reading with 5 MB/s.

 

Couldn=E2=80=99t fin= d a fast query for my problem.

 

So I wrote a java-program which read the whole table = at a fetchsize of about 4 million and inserted the names into a HashSet.

And surprisingly after only a few minutes the program= was already 25% done o.O

 

My question is, why isn=E2=80=99t postgres nearly this fas= t? Why doesn=E2=80=99t it just create a HashSet in RAM and read full speed = from the disk?

I even created a hash index but it k= ept using it=E2=80=99s primary key b-tree and then I read that hash indices= somehow don=E2=80=99t support checking for uniqueness.

 

Best regards, Tobi

 


3D"" Virus-= free. www.avast.com
--_23E75512-C156-46F4-9330-C7A03079D160_--