Re: Anyone for SSDs?

Lists: pgsql-hackers
From: Daniel Loureiro <loureirorg(at)gmail(dot)com>
To: Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Anyone for SSDs?
Date: 2010-12-10 20:21:33
Message-ID: AANLkTinia5uFimyc__CR83s7-58coOvWYY1EzZ8spD=L@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

>> Most of you already know I am new to this list and newer to any OSS
>> development. However, while browsing the source code (of 9.0.1) I find
>> that there is only one way to store relations on disk - the magnetic
>> disk.

>The fact that it's called md.c is a hangover from the '80s. These days,
>the logic that the Berkeley guys envisioned being at that code level
>is generally in kernel device drivers. md.c can drive anything that
>behaves as a block device + filesystem, which is pretty much everything
>of interest.

I believe that PostgreSQL was been developed and optimized for
sequential access. To get full advantage of SSDs its necessary to
rewrite almost the whole project - there are so much code written with
the sequential mechanism in mind.

--
Daniel Loureiro


From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Daniel Loureiro <loureirorg(at)gmail(dot)com>
Cc: Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Anyone for SSDs?
Date: 2010-12-10 22:15:46
Message-ID: AANLkTikSP2O-zo+m8L3TwkbK+xFaqtS-R7wJymeR59=K@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Dec 10, 2010 at 12:21 PM, Daniel Loureiro <loureirorg(at)gmail(dot)com> wrote:
>>> Most of you already know I am new to this list and newer to any OSS
>>> development. However, while browsing the source code (of 9.0.1) I find
>>> that there is only one way to store relations on disk - the magnetic
>>> disk.
>
>>The fact that it's called md.c is a hangover from the '80s.  These days,
>>the logic that the Berkeley guys envisioned being at that code level
>>is generally in kernel device drivers.  md.c can drive anything that
>>behaves as a block device + filesystem, which is pretty much everything
>>of interest.
>
> I believe that PostgreSQL was been developed and optimized for
> sequential access. To get full advantage of SSDs its necessary to
> rewrite almost the whole project - there are so much code written with
> the sequential mechanism in mind.

I don't think that that is true at all. If you tell the planner that
a random page and a sequential page have the same cost, does it not
believe you?

Of course if you do a full table scan because their are no better
options, then it scans sequentially. But you have to scan the pages
in *some* order, and it is hard to see how something other than
sequential would be systematically better.

Cheers,

Jeff


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
Cc: Daniel Loureiro <loureirorg(at)gmail(dot)com>, Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Anyone for SSDs?
Date: 2010-12-10 22:49:14
Message-ID: 2175.1292021354@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Jeff Janes <jeff(dot)janes(at)gmail(dot)com> writes:
> Of course if you do a full table scan because their are no better
> options, then it scans sequentially. But you have to scan the pages
> in *some* order, and it is hard to see how something other than
> sequential would be systematically better.

In fact, if sequential *isn't* the best order for reading the whole
file, the filesystem has lost its marbles completely; because that is
the order in which most files are read, so files ought to be laid out
on disk (or whatever storage device) to be read most quickly that way.

regards, tom lane


From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Daniel Loureiro <loureirorg(at)gmail(dot)com>
Cc: Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Anyone for SSDs?
Date: 2010-12-10 23:08:01
Message-ID: 4D02B2D1.3000900@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


> I believe that PostgreSQL was been developed and optimized for
> sequential access. To get full advantage of SSDs its necessary to
> rewrite almost the whole project - there are so much code written with
> the sequential mechanism in mind.

You can believe whatever you want, that doesn't make it true.

Unless you have some kind of hard data that SSD data access is somehow
*qualitatively* different from SAS data access, then you're just
engaging in idle water-cooler speculation.

Plenty of vendors launched products based on the supposed
"revolutionary" nature of SSDs when they first came out. All have
failed. SSDs are just faster disks, that's all. Their ratio of
random-access to sequential might be less than 4.0, but it's not 1.0.

Heck, even RAM isn't 1.0. I'm also involved with the Redis project,
which is an in-memory database. Even for a pure-RAM database, it turns
out that just using linked lists and 100% random access is slower than
accessing page images.

I use SSDs for many PostgreSQL instances. They work great. No changes
to PostgreSQL were required other than adjusting random_page_cost down
to 2.0 (this number could use exhaustive testing, but seems to work
pretty well right now).

--
-- Josh Berkus
PostgreSQL Experts Inc.
http://www.pgexperts.com


From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: Daniel Loureiro <loureirorg(at)gmail(dot)com>, Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Anyone for SSDs?
Date: 2010-12-10 23:13:23
Message-ID: 1292022803.3319.59.camel@jd-desktop
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, 2010-12-10 at 15:08 -0800, Josh Berkus wrote:
> > I believe that PostgreSQL was been developed and optimized for
> > sequential access. To get full advantage of SSDs its necessary to
> > rewrite almost the whole project - there are so much code written with
> > the sequential mechanism in mind.
>
> You can believe whatever you want, that doesn't make it true.

Or more productively.

Actually, the only (that I know of) optimized for sequential access code
we have would be for the xlogs. All of the page writing within the
cluster would be random, as would all logging outside of the WAL itself.

Sincerely,

Joshua D. Drake

--
PostgreSQL.org Major Contributor
Command Prompt, Inc: http://www.commandprompt.com/ - 509.416.6579
Consulting, Training, Support, Custom Development, Engineering
http://twitter.com/cmdpromptinc | http://identi.ca/commandprompt


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: Daniel Loureiro <loureirorg(at)gmail(dot)com>, Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Anyone for SSDs?
Date: 2010-12-10 23:14:18
Message-ID: AANLkTinpYcyz+E4N=br3946jbLRpV1bFmJO4eBi7CqkS@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Dec 10, 2010 at 6:08 PM, Josh Berkus <josh(at)agliodbs(dot)com> wrote:
> Heck, even RAM isn't 1.0.  I'm also involved with the Redis project,
> which is an in-memory database.  Even for a pure-RAM database, it turns
> out that just using linked lists and 100% random access is slower than
> accessing page images.

That's a slightly different problem, though. Sequential vs. random
access is about whether fetching pages n, n+1, n+2, ... is faster than
skipping around, not whether accessing fewer pages is faster than
more.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Daniel Loureiro <loureirorg(at)gmail(dot)com>, Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Anyone for SSDs?
Date: 2010-12-10 23:39:04
Message-ID: 4D02BA18.2080105@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


>> Heck, even RAM isn't 1.0. I'm also involved with the Redis project,
>> which is an in-memory database. Even for a pure-RAM database, it turns
>> out that just using linked lists and 100% random access is slower than
>> accessing page images.
>
> That's a slightly different problem, though. Sequential vs. random
> access is about whether fetching pages n, n+1, n+2, ... is faster than
> skipping around, not whether accessing fewer pages is faster than
> more.

It's not though. Redis stores stuff as lists and sets, so it actually
does a lot of sequential access of data. Like if people are accessing
an ordered set, they're usually pulling the whole thing. It turns out
that *even in RAM* storing stuff in an ordered fashion on data "pages"
is more efficient than just using pointers.

--
-- Josh Berkus
PostgreSQL Experts Inc.
http://www.pgexperts.com


From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: jd(at)commandprompt(dot)com
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, Daniel Loureiro <loureirorg(at)gmail(dot)com>, Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Anyone for SSDs?
Date: 2010-12-10 23:44:46
Message-ID: AANLkTi=x0eayUs1wfYmjLne1D4-zk64eK8=6aGxwVgOd@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Dec 10, 2010 at 3:13 PM, Joshua D. Drake <jd(at)commandprompt(dot)com> wrote:
>
> Actually, the only (that I know of) optimized for sequential access code
> we have would be for the xlogs.

And even that is more of a book-keeping simplification, rather than an
optimization.

You have to know where to find the logically next (in a PG sense)
record. If the logically next record is
not right after (in a file system sense) the previous record, then
where is it and how do you find it?

If you really wanted to make it non-sequential, you could, with a
substantial amount of work. But why
would you want to? On spinning rust, you might want to try
leap-frogging the platter, but that is
never going to be generalizable to different work-loads, much less
different hardware.

Cheers,

Jeff


From: Hannu Krosing <hannu(at)2ndquadrant(dot)com>
To: Daniel Loureiro <loureirorg(at)gmail(dot)com>
Cc: Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Anyone for SSDs?
Date: 2010-12-10 23:47:17
Message-ID: 4D02BC05.2030406@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 10.12.2010 21:21, Daniel Loureiro wrote:
>
>> The fact that it's called md.c is a hangover from the '80s. These days,
>> the logic that the Berkeley guys envisioned being at that code level
>> is generally in kernel device drivers. md.c can drive anything that
>> behaves as a block device + filesystem, which is pretty much everything
>> of interest.
> I believe that PostgreSQL was been developed and optimized for
> sequential access. To get full advantage of SSDs its necessary to
> rewrite almost the whole project - there are so much code written with
> the sequential mechanism in mind.
Nope, as a matter of fact postgreSQL was developed as a university
project with flexibility and extensibility among top goals.
Yes, "magnetic disk" is the only storage manager left in current code
base, but the original design had more, most notably the WORM (Write
Once Read Many) disks, one of the uses being for the old design of
VACUUM which did not throw away deleted rows but moved them to WORM
disks for historical queries. The WORM disks were the "next big thing in
storage" a few tens of years ago.

And as Josh Berkus notes in another replay, nowadays even RAM is not
neutral to access patterns - pipeline stalls and cache flushes can have
impact of several orders of magnitude on execution speeds.

----------------------
Hannu Krosing
PostgreSQL Infinite Scalability and High Availability
http://www.2ndquadrant.com/books/


From: Daniel Loureiro <daniel(at)termasa(dot)com(dot)br>
To: Hannu Krosing <hannu(at)2ndquadrant(dot)com>
Cc: Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Anyone for SSDs?
Date: 2010-12-11 00:37:23
Message-ID: AANLkTimF2vxCX2W_Gk4vFnowmMoV+MnQVNUEND+mWM1G@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

> You can believe whatever you want, that doesn't make it true.
completely agree. Like yours, Its just my point of view, not the reality.

I agree with most points here, but I wondering how many good ideas are
killed with the thought: "this will be a performance killer with so
many random access, lets discarded it". If in 80's the sequential
access has more cost compared with random access (ok, there's not the
SSD case), will be the PostgreSQL in the same design that it have
nowadays ?

--
Daniel Loureiro.


From: Daniel Loureiro <loureirorg(at)gmail(dot)com>
To: Hannu Krosing <hannu(at)2ndquadrant(dot)com>
Cc: Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Anyone for SSDs?
Date: 2010-12-11 01:06:57
Message-ID: AANLkTi=35F2NmHkdYuzj98gCzVbBS+WB6xvUqJ3jjVtb@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

> You can believe whatever you want, that doesn't make it true.
completely agree. Like yours, Its just my point of view, not the reality.

I agree with some points here, but I wondering how many good ideas are
killed with the thought: "this will be a performance killer with so
many random access, lets discarded it". An quicksort method in
sequential disk its just awful to be thinking in a non SSD world, but
its possible in an SSD.

If in 80's the sequential access has more cost compared with random
access will be the PostgreSQL in the same design that it have nowadays
?

--
Daniel Loureiro


From: Josh Berkus <josh(at)agliodbs(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Anyone for SSDs?
Date: 2010-12-11 02:07:24
Message-ID: 4D02DCDC.7000600@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 12/10/10 5:06 PM, Daniel Loureiro wrote:
> An quicksort method in
> sequential disk its just awful to be thinking in a non SSD world, but
> its possible in an SSD.

So, code it. Shouldn't be hard to write a demo comparison. I don't
believe that SSDs make quicksort-on-disk feasible, but would be happy to
be proven wrong.

--
-- Josh Berkus
PostgreSQL Experts Inc.
http://www.pgexperts.com


From: Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Anyone for SSDs?
Date: 2010-12-11 04:09:10
Message-ID: 1292040550.2580.148.camel@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, 2010-12-10 at 18:07 -0800, Josh Berkus wrote:
> On 12/10/10 5:06 PM, Daniel Loureiro wrote:
> > An quicksort method in
> > sequential disk its just awful to be thinking in a non SSD world, but
> > its possible in an SSD.
>
> So, code it. Shouldn't be hard to write a demo comparison. I don't
> believe that SSDs make quicksort-on-disk feasible, but would be happy to
> be proven wrong.

I too do not believe it in normal case. However, considering the 'types'
of SSDs, it may be feasible! Asking for 'the next page and getting it'
has a time delay in the process. While on a regular HDD with spindles,
the question is "where is that page located", with SSDs, the question
disappears, because the access time is uniform in case of SSDs. Also,
the access time is about 100 times fasterm which would change quite a
few things about the whole process.

I would like to do that (coding), but I do not have a SSD on my
machine! :( Would it be impractical to try it for me? Again I do not
know how to test PG :(

May be some of those I meet on the chat, and are into the enterprise may
do it, but I would like to be a part of it.

-Vaibhav (*_*)


From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Anyone for SSDs?
Date: 2010-12-11 04:19:53
Message-ID: 20101211041953.GK26232@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

* Vaibhav Kaushal (vaibhavkaushal123(at)gmail(dot)com) wrote:
> I would like to do that (coding), but I do not have a SSD on my
> machine! :( Would it be impractical to try it for me? Again I do not
> know how to test PG :(

No, it's not a trivial amount of work. Perhaps someone will be curious
enough to try it, but I wouldn't count on it.

Stephen


From: Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Anyone for SSDs?
Date: 2010-12-11 04:21:48
Message-ID: 1292041308.2580.149.camel@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, 2010-12-10 at 23:19 -0500, Stephen Frost wrote:
> * Vaibhav Kaushal (vaibhavkaushal123(at)gmail(dot)com) wrote:
> > I would like to do that (coding), but I do not have a SSD on my
> > machine! :( Would it be impractical to try it for me? Again I do not
> > know how to test PG :(
>
> No, it's not a trivial amount of work. Perhaps someone will be curious
> enough to try it, but I wouldn't count on it.
>
> Stephen
Well, thanks for the word.

-Vaibhav (^_^)


From: Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Anyone for SSDs?
Date: 2010-12-11 08:49:51
Message-ID: 1292057391.2580.151.camel@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, 2010-12-10 at 18:07 -0800, Josh Berkus wrote:
> On 12/10/10 5:06 PM, Daniel Loureiro wrote:
> > An quicksort method in
> > sequential disk its just awful to be thinking in a non SSD world, but
> > its possible in an SSD.
>
> So, code it. Shouldn't be hard to write a demo comparison. I don't
> believe that SSDs make quicksort-on-disk feasible, but would be happy to
> be proven wrong.

I too do not believe it in normal case. However, considering the 'types'
of SSDs, it may be feasible! Asking for 'the next page and getting it'
has a time delay in the process. While on a regular HDD with spindles,
the question is "where is that page located", with SSDs, the question
disappears, because the access time is uniform in case of SSDs. Also,
the access time is about 100 times fasterm which would change quite a
few things about the whole process.

I would like to do that, but I do not have a SSD on my machine! :( Would
it be impractical to try it for me?

May be some of those I meet on the chat, and are into the enterprise may
do it, but I would like to be a part of it.

-Vaibhav (*_*)


From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Anyone for SSDs?
Date: 2010-12-11 19:09:07
Message-ID: AANLkTim5tRuJQTsxr-Vp=VLnNEvkd2Nn-rpP+2WV3aQt@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Dec 10, 2010 at 8:09 PM, Vaibhav Kaushal
<vaibhavkaushal123(at)gmail(dot)com> wrote:
> On Fri, 2010-12-10 at 18:07 -0800, Josh Berkus wrote:
>> On 12/10/10 5:06 PM, Daniel Loureiro wrote:
>> > An quicksort method in
>> > sequential disk its just awful to be thinking in a non SSD world, but
>> > its possible in an SSD.
>>
>> So, code it.  Shouldn't be hard to write a demo comparison.  I don't
>> believe that SSDs make quicksort-on-disk feasible, but would be happy to
>> be proven wrong.
>
> I too do not believe it in normal case. However, considering the 'types'
> of SSDs, it may be feasible! Asking for 'the next page and getting it'
> has a time delay in the process. While on a regular HDD with spindles,
> the question is "where is that page located", with SSDs, the question
> disappears, because the access time is uniform in case of SSDs. Also,
> the access time is about 100 times fasterm which would change quite a
> few things about the whole process.

I don't understand what it is you are proposing. Quicksort is usually
swap based, and so the records would need to be the same size. Are
you proposing to do an in-memory sort of pointers, which reference
on-disk records? Or an on-disk sort of pointers which reference
on-disk (but somewhere else) records? If you are swapping pointers on
disk, you have to consider the write performance, not just the read
performance.

> I would like to do that (coding), but I do not have a SSD on my
> machine!

That doesn't mean you can't do the coding, it just means you can't
test the performance.
The barrier to get someone else to performance test it for you is a
lot lower than the
barrier to get someone else to write it for you and then performance
test it for you.
(But I can't test-drive it, as I don't have any computer which has
both an SSD and
a hard drive, just one or the other. And the one with SSD would be
hard to compile
PG on.)

> :( Would it be impractical to try it for me? Again I do not
> know how to test PG :(

Yeah, I think it would be impractical. If I thought it would likely
work, it would be different (at least, it might be if I had the right
hardware).
But I think it would likely not work.

Cheers,

Jeff


From: Chris Browne <cbbrowne(at)acm(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Anyone for SSDs?
Date: 2010-12-13 22:06:02
Message-ID: 87lj3tz5th.fsf@cbbrowne.afilias-int.info
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

loureirorg(at)gmail(dot)com (Daniel Loureiro) writes:
>> You can believe whatever you want, that doesn't make it true.
> completely agree. Like yours, Its just my point of view, not the reality.
>
> I agree with some points here, but I wondering how many good ideas are
> killed with the thought: "this will be a performance killer with so
> many random access, lets discarded it". An quicksort method in
> sequential disk its just awful to be thinking in a non SSD world, but
> its possible in an SSD.
>
> If in 80's the sequential access has more cost compared with random
> access will be the PostgreSQL in the same design that it have nowadays
> ?

What turns out to be surprising is that the behaviours of new kinds of
media not infrequently retrieve the usefulness of algorithms designed
for elderly sorts of media.

The entertaining one, on Postgres, has been that the behaviour of fairly
large amounts of memory, as compared to the slower access rates for disk
has led to retrieving tape-oriented algorithms from
thought-to-be-obsolete literature.

I don't think it's too likely that SSD changes this.

But what is rather interesting is that the issue *isn't* one of how fast
it is to sort things on disk - it is of how to sort in memory.

It's quite feasible to load blocks of data into memory, sort in memory,
via [some means], and then do tape merges to get the fully ordered
result that is then sequentially written out to disk.

Replacing [some means] with Quicksort is a plausible idea. I doubt it'd
be an improvement on what is already there, but there's already room for
it to work.
--
let name="cbbrowne" and tld="gmail.com" in name ^ "@" ^ tld;;
http://linuxdatabases.info/info/nonrdbms.html
Outside of a dog, a book is man's best friend. Inside of a dog, it's
too dark to read. -Groucho Marx


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, Daniel Loureiro <loureirorg(at)gmail(dot)com>, Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Anyone for SSDs?
Date: 2010-12-29 20:11:18
Message-ID: 201012292011.oBTKBIb14178@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:
> Jeff Janes <jeff(dot)janes(at)gmail(dot)com> writes:
> > Of course if you do a full table scan because their are no better
> > options, then it scans sequentially. But you have to scan the pages
> > in *some* order, and it is hard to see how something other than
> > sequential would be systematically better.
>
> In fact, if sequential *isn't* the best order for reading the whole
> file, the filesystem has lost its marbles completely; because that is
> the order in which most files are read, so files ought to be laid out
> on disk (or whatever storage device) to be read most quickly that way.

Plus kernel read-ahead helps with sequential access too because the
kernel can guess the next blocks to be requested --- hard to do that
with random I/O. SSD have fast access but still benefit from
read-ahead.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Anyone for SSDs?
Date: 2010-12-29 20:18:48
Message-ID: 201012292018.oBTKIml15015@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Vaibhav Kaushal wrote:
> On Fri, 2010-12-10 at 18:07 -0800, Josh Berkus wrote:
> > On 12/10/10 5:06 PM, Daniel Loureiro wrote:
> > > An quicksort method in
> > > sequential disk its just awful to be thinking in a non SSD world, but
> > > its possible in an SSD.
> >
> > So, code it. Shouldn't be hard to write a demo comparison. I don't
> > believe that SSDs make quicksort-on-disk feasible, but would be happy to
> > be proven wrong.
>
> I too do not believe it in normal case. However, considering the 'types'
> of SSDs, it may be feasible! Asking for 'the next page and getting it'
> has a time delay in the process. While on a regular HDD with spindles,
> the question is "where is that page located", with SSDs, the question
> disappears, because the access time is uniform in case of SSDs. Also,
> the access time is about 100 times fasterm which would change quite a
> few things about the whole process.

What _is_ interesting is that Postgres often has sequential and
random/disk ways of doing things, and by reducing random_page_cost when
using SSDs, you automatically use more random operations, so in a way
the Postgres code was already prepared for SSD usage. Surprisingly, we
had to change very little.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Anyone for SSDs?
Date: 2010-12-29 20:34:03
Message-ID: 201012292034.oBTKY3R16557@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Bruce Momjian wrote:
> Vaibhav Kaushal wrote:
> > On Fri, 2010-12-10 at 18:07 -0800, Josh Berkus wrote:
> > > On 12/10/10 5:06 PM, Daniel Loureiro wrote:
> > > > An quicksort method in
> > > > sequential disk its just awful to be thinking in a non SSD world, but
> > > > its possible in an SSD.
> > >
> > > So, code it. Shouldn't be hard to write a demo comparison. I don't
> > > believe that SSDs make quicksort-on-disk feasible, but would be happy to
> > > be proven wrong.
> >
> > I too do not believe it in normal case. However, considering the 'types'
> > of SSDs, it may be feasible! Asking for 'the next page and getting it'
> > has a time delay in the process. While on a regular HDD with spindles,
> > the question is "where is that page located", with SSDs, the question
> > disappears, because the access time is uniform in case of SSDs. Also,
> > the access time is about 100 times fasterm which would change quite a
> > few things about the whole process.
>
> What _is_ interesting is that Postgres often has sequential and
> random/disk ways of doing things, and by reducing random_page_cost when
> using SSDs, you automatically use more random operations, so in a way
> the Postgres code was already prepared for SSD usage. Surprisingly, we
> had to change very little.

To add to this very late reply, we basically had random methods to do
things (in RAM), and sequential/random methods for disk. By changing
random_page_cost, we favor doing random things on disk.

The big question is whether there are random things we have never
implemented on disk that now make sense --- off hand, I can't think of
any.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Robert Treat <rob(at)xzilla(dot)net>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Anyone for SSDs?
Date: 2010-12-29 23:45:49
Message-ID: AANLkTin3RQGSuG2O4hFqJ+gBVu8jpJMtvPiHCkpeVXEV@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Dec 29, 2010 at 3:34 PM, Bruce Momjian <bruce(at)momjian(dot)us> wrote:

> Bruce Momjian wrote:
> > Vaibhav Kaushal wrote:
> > > On Fri, 2010-12-10 at 18:07 -0800, Josh Berkus wrote:
> > > > On 12/10/10 5:06 PM, Daniel Loureiro wrote:
> > > > > An quicksort method in
> > > > > sequential disk its just awful to be thinking in a non SSD world,
> but
> > > > > its possible in an SSD.
> > > >
> > > > So, code it. Shouldn't be hard to write a demo comparison. I don't
> > > > believe that SSDs make quicksort-on-disk feasible, but would be happy
> to
> > > > be proven wrong.
> > >
> > > I too do not believe it in normal case. However, considering the
> 'types'
> > > of SSDs, it may be feasible! Asking for 'the next page and getting it'
> > > has a time delay in the process. While on a regular HDD with spindles,
> > > the question is "where is that page located", with SSDs, the question
> > > disappears, because the access time is uniform in case of SSDs. Also,
> > > the access time is about 100 times fasterm which would change quite a
> > > few things about the whole process.
> >
> > What _is_ interesting is that Postgres often has sequential and
> > random/disk ways of doing things, and by reducing random_page_cost when
> > using SSDs, you automatically use more random operations, so in a way
> > the Postgres code was already prepared for SSD usage. Surprisingly, we
> > had to change very little.
>
> To add to this very late reply, we basically had random methods to do
> things (in RAM), and sequential/random methods for disk. By changing
> random_page_cost, we favor doing random things on disk.
>
> The big question is whether there are random things we have never
> implemented on disk that now make sense --- off hand, I can't think of
> any.
>
>
The idea of us avoiding quicksort when we know we need to spill to disk is
the type of thing that I wonder if it should be investigated, if you figure
that "spill to disk" means ssd's so it's not so much of a performance
hit. This reminds me of some performance testing we did maybe a year, year
and a half ago, trying to see how best to get performance by adding some
SSD's into one of our servers. Basically speed increased as we changed
things like so:
put entire $pgdata on sata
put entire $pgdata on ssd
put xlogs on ssd, pgdata on sata
put pgdata and xlogs on sata, put arc on ssd, crank up postgres's memory
settings

arc being zfs's adaptive replacement cache, so basically giving the server a
second, very large level of memory to work with, and then configuring
postgres to make use of it. It wasn't terribly obvious to me why this ended
up outperforming the initial idea of putting everything on ssd, but my
impression was that the more you could force postgres into making decisions
as if it was dealing with fast storage rather than slow storage, the better
off you'd be (and that random_page_cost is not so wholly inclusive enough to
do this for you).

Robert Treat
http://www.xzilla.net


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Robert Treat <rob(at)xzilla(dot)net>
Cc: Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Anyone for SSDs?
Date: 2011-01-01 20:58:37
Message-ID: 201101012058.p01KwbF21825@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Robert Treat wrote:
> > > What _is_ interesting is that Postgres often has sequential and
> > > random/disk ways of doing things, and by reducing random_page_cost when
> > > using SSDs, you automatically use more random operations, so in a way
> > > the Postgres code was already prepared for SSD usage. Surprisingly, we
> > > had to change very little.
> >
> > To add to this very late reply, we basically had random methods to do
> > things (in RAM), and sequential/random methods for disk. By changing
> > random_page_cost, we favor doing random things on disk.
> >
> > The big question is whether there are random things we have never
> > implemented on disk that now make sense --- off hand, I can't think of
> > any.
> >
> >
> The idea of us avoiding quicksort when we know we need to spill to disk is

You mean using quicksort from an (SSD) disk vs. tape sorts --- good
point.

> the type of thing that I wonder if it should be investigated, if you figure
> that "spill to disk" means ssd's so it's not so much of a performance
> hit. This reminds me of some performance testing we did maybe a year, year
> and a half ago, trying to see how best to get performance by adding some
> SSD's into one of our servers. Basically speed increased as we changed
> things like so:
> put entire $pgdata on sata
> put entire $pgdata on ssd
> put xlogs on ssd, pgdata on sata
> put pgdata and xlogs on sata, put arc on ssd, crank up postgres's memory
> settings
>
> arc being zfs's adaptive replacement cache, so basically giving the server a
> second, very large level of memory to work with, and then configuring
> postgres to make use of it. It wasn't terribly obvious to me why this ended
> up outperforming the initial idea of putting everything on ssd, but my
> impression was that the more you could force postgres into making decisions
> as if it was dealing with fast storage rather than slow storage, the better
> off you'd be (and that random_page_cost is not so wholly inclusive enough to
> do this for you).

Yes, I wonder if this requires futher investigation.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +