From: James(王旭) <wangxu@gu360.com>
To: Luca Ferrari <fluca1978@gmail.com>
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: Issue related with patitioned table:How can I quickly determine which child table my record is in,given a specific primary key value?
Date: Wed, 17 Jul 2019 17:40:59 +0800
Message-ID: <tencent_3DC4B18C6E40FB7B57E655F2@qq.com> (raw)
In-Reply-To: <tencent_3398A66F571334E95E5B4093@qq.com>
References: <tencent_267C505771F9162A6E330836@qq.com>
<CAKoxK+64bLMR8nuMyrRwjvQD90o4e=LVNgEMysy16btuwmhXKg@mail.gmail.com>
<tencent_3398A66F571334E95E5B4093@qq.com>
Here's my PG version:
PostgreSQL 11.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36), 64-bit
Hope this helps.
------------------ Original ------------------
From: "James(王旭)"<wangxu@gu360.com>;
Date: Wed, Jul 17, 2019 05:36 PM
To: "Luca Ferrari"<fluca1978@gmail.com>;
Cc: "pgsql-general"<pgsql-general@lists.postgresql.org>;
Subject: Re: Issue related with patitioned table:How can I quickly determine which child table my record is in,given a specific primary key value?
Thanks you Luca.
Yes my intention was " SELECT (hashint2(6365::SMALLINT)% 3) ", that's my mistake, thank you for pointing out.
Actually I just did a simple query in my single table:
SELECT distinct(symbol_id) FROM xxxx_0
and I got these results:
"symbol_id"
6521
1478
1964
5642
7470
1158
2429
9882
4542
5196
9178
8303
1091
9435
8133
1437
9072
From these results I can tell the route to a table is not even related with the mod function, right?
So It's hard for me to do any kind of guesses...
------------------ Original ------------------
From: "Luca Ferrari"<fluca1978@gmail.com>;
Date: Wed, Jul 17, 2019 05:13 PM
To: "王旭"<wangxu@gu360.com>;
Cc: "pgsql-general"<pgsql-general@lists.postgresql.org>;
Subject: Re: Issue related with patitioned table:How can I quickly determine which child table my record is in,given a specific primary key value?
On Wed, Jul 17, 2019 at 9:19 AM 王旭 <wangxu@gu360.com> wrote:
> I tried something like this: e.g., for symbol_id 6365,
> SELECT (hashint2(6365::SMALLINT)% 10)
shouldn't this be modulus 3 instead of 10?
The problem is that record 6365 is not where you expected to be?
As far as I know, there is no easy user-level way to get the route to
a table, but you can juggle with the expression that defined each
table and make a good guess.
However, your query should give a good idea:
# SELECT 'my_table_' || (hashint2(6365::smallint)% 3);
?column?
------------
my_table_2
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: wangxu@gu360.com, fluca1978@gmail.com
Subject: Re: Issue related with patitioned table:How can I quickly determine which child table my record is in,given a specific primary key value?
In-Reply-To: <tencent_3DC4B18C6E40FB7B57E655F2@qq.com>
References: <tencent_267C505771F9162A6E330836@qq.com> <CAKoxK+64bLMR8nuMyrRwjvQD90o4e=LVNgEMysy16btuwmhXKg@mail.gmail.com> <tencent_3398A66F571334E95E5B4093@qq.com> <tencent_3DC4B18C6E40FB7B57E655F2@qq.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox