how to reach D5 in tuplesort.c 's polyphase merge algorithm?

Started by 土卜皿over 11 years ago4 messages
#1土卜皿
pengcz.nwpu@gmail.com

hi, all
for studying polyphase merge algorithm of tuplesort.c, I use ddd and
apend a table, which has a schema as follows:

CREATE TABLE Towns (
id SERIAL UNIQUE NOT NULL,
code VARCHAR(10) NOT NULL, -- Only unique inside a department
article TEXT,
name TEXT NOT NULL, -- Names are not really unique, for instance
'Sainte-Croix'
department VARCHAR(4) NOT NULL REFERENCES Departments (code),
UNIQUE (code, department)
-- UNIQUE (name, department) -- Not perfectly unique but almost
);

and has 36684 records, and every record is like:
id code article name department
31800 266 \N Machault 77

and for getting into external sort, I type the following command:

select * from towns order by name desc;

but I found it need not reach D5 and D6 during sorting, I thought that the
reason is the amount of runs is 3 (too small) before merging, for generate
more runs, I shuffled the records
when inputting them and got the same result.

so that I want some help, what schema and records do I as least need for
reaching D5 and D6? any advice will be appreciated!

BEST REGAERDS
Dillon

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: 土卜皿 (#1)
Re: how to reach D5 in tuplesort.c 's polyphase merge algorithm?

=?UTF-8?B?5Zyf5Y2c55q/?= <pengcz.nwpu@gmail.com> writes:

for studying polyphase merge algorithm of tuplesort.c, I use ddd and
apend a table, which has a schema as follows:
...
and has 36684 records, and every record is like:
id code article name department
31800 266 \N Machault 77

and for getting into external sort, I type the following command:

select * from towns order by name desc;

but I found it need not reach D5 and D6 during sorting,

That doesn't sound like enough data to force it to spill to disk at all;
at least not unless you turn down work_mem to some very small value.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3土卜皿
pengcz.nwpu@gmail.com
In reply to: Tom Lane (#2)
Re: how to reach D5 in tuplesort.c 's polyphase merge algorithm?

2014-07-19 6:26 GMT+08:00 Tom Lane <tgl@sss.pgh.pa.us>:

=?UTF-8?B?5Zyf5Y2c55q/?= <pengcz.nwpu@gmail.com> writes:

for studying polyphase merge algorithm of tuplesort.c, I use ddd and
apend a table, which has a schema as follows:
...
and has 36684 records, and every record is like:
id code article name department
31800 266 \N Machault 77

and for getting into external sort, I type the following command:

select * from towns order by name desc;

but I found it need not reach D5 and D6 during sorting,

That doesn't sound like enough data to force it to spill to disk at all;
at least not unless you turn down work_mem to some very small value.

hi, Tom
thanks a lot!

work_mem you said remind me one more thing I did, I tried to change BLCKSZ
= 8192/2, and successfully compiled, but I got a error when executing
initdb

Dillon

#4土卜皿
pengcz.nwpu@gmail.com
In reply to: 土卜皿 (#3)
Re: how to reach D5 in tuplesort.c 's polyphase merge algorithm?

hi,
I got the same result after work_mem = 64,
but I can get to D5 and D6 after using bigger data sample (at least 100000
records) as Tom said!

2014-07-19 6:35 GMT+08:00 土卜皿 <pengcz.nwpu@gmail.com>:

Show quoted text

2014-07-19 6:26 GMT+08:00 Tom Lane <tgl@sss.pgh.pa.us>:

=?UTF-8?B?5Zyf5Y2c55q/?= <pengcz.nwpu@gmail.com> writes:

for studying polyphase merge algorithm of tuplesort.c, I use ddd and
apend a table, which has a schema as follows:
...
and has 36684 records, and every record is like:
id code article name department
31800 266 \N Machault 77

and for getting into external sort, I type the following command:

select * from towns order by name desc;

but I found it need not reach D5 and D6 during sorting,

That doesn't sound like enough data to force it to spill to disk at all;
at least not unless you turn down work_mem to some very small value.

hi, Tom
thanks a lot!

work_mem you said remind me one more thing I did, I tried to change BLCKSZ
= 8192/2, and successfully compiled, but I got a error when executing
initdb

Dillon