Beta

×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

PostgreSQL 9.2 Out with Greatly Improved Scalability

Unknown Lamer posted about 2 years ago | from the rev-your-engines dept.

Databases 146

The PostgreSQL project announced the release of PostgreSQL 9.2 today. The headliner: "With the addition of linear scalability to 64 cores, index-only scans and reductions in CPU power consumption, PostgreSQL 9.2 has significantly improved scalability and developer flexibility for the most demanding workloads. ... Up to 350,000 read queries per second (more than 4X faster) ... Index-only scans for data warehousing queries (2–20X faster) ... Up to 14,000 data writes per second (5X faster)" Additionally, there's now a JSON type (including the ability to retrieve row results in JSON directly from the database) ala the XML type (although lacking a broad set of utility functions). Minor, but probably a welcome relief to those who need them, 9.2 adds range restricted types. For the gory details, see the what's new page, or the full release notes.

cancel ×

146 comments

Sorry! There are no comments related to the filter you selected.

/. Poll (-1, Offtopic)

Anonymous Coward | about 2 years ago | (#41294267)

If you're sitting alone in your cube, and you suddenly smell a horrible fecal smell, you should:
A) Loudly blame the lady in the next cube over to divert attention from yourself
B) Go to the bathroom to check your underwear for unexpected deposits
C) Just get up and leave for 5 minutes to let the dissipate
D) Spray some air freshener around and keep coding

Re:/. Poll (-1)

Anonymous Coward | about 2 years ago | (#41294317)

Keep coding. Duh.

Re:/. Poll (-1)

Anonymous Coward | about 2 years ago | (#41294347)

For most of the neckbeards here? Excuse themselves for burping and go brush their teeth.

Re:/. Poll (4, Insightful)

Eponymous Hero (2090636) | about 2 years ago | (#41294351)

E) stop using oracle and start using postgres

Re:/. Poll (-1, Offtopic)

HornWumpus (783565) | about 2 years ago | (#41294411)

Go home and 'arm' yourself with kim-chi, hard boiled almost expired eggs, beans, brown rice, onions and cheap beer. And milk and cheese if you are lactose intolerant.

'They' started it, it's your job to finish it.

Re:/. Poll (-1)

Anonymous Coward | about 2 years ago | (#41294713)

Get rid of the Microsoft server and the MS coders. They obviously died and defecated.

LOL (-1)

Anonymous Coward | about 2 years ago | (#41294353)

LOL just use SQLServer you nubs.

Re:LOL (1, Informative)

Anonymous Coward | about 2 years ago | (#41294403)

Because we love to bash our keyboards into so much plastic scrap whenever we come across one of its many standards-defiant idiosyncracies?

Re:LOL (2, Insightful)

Tough Love (215404) | about 2 years ago | (#41295567)

Because we love to bash our keyboards into so much plastic scrap whenever we come across one of its many standards-defiant idiosyncracies?

You mean, idiosyncracies different from Oracle's idiosyncracies, Microsoft's idiosyncracies and IBM's idiosyncracies?

By the way, care to be specific? Oh yeah, posting anon. Right.

Re:LOL (0)

Anonymous Coward | about 2 years ago | (#41295787)

No, different from PostgreSQL.

Re:LOL (1)

colinrichardday (768814) | about 2 years ago | (#41296011)

How are SQL Server's idiosyncracies different from Microsoft's? Isn't SQL Server a Microsoft product?

Re:LOL (0)

hobarrera (2008506) | about 2 years ago | (#41298405)

Did you even read the article? The article talks about PostgreSQL, which is an SQL Server from a different vender. There's also MySQL, and plenty of other SQL Servers.

Re:LOL (1)

Anonymous Coward | about 2 years ago | (#41298831)

"SQL Server" is not some generic name for a relational database -- it's a product from Microsoft. So "SQL Server", "PostgreSQL", "MySQL" etc are all relational database servers, not "SQL Servers".

Re:LOL (0)

Zaphod The 42nd (1205578) | about 2 years ago | (#41301091)

Wrong, actually, be careful. The product from MS is "Microsoft SQL Server"

"SQL Server" is just a generic name of which there are many, many implementations. Parent was spot on.

http://en.wikipedia.org/wiki/SQL_Server [wikipedia.org]

Quote Wikipedia:
SQL Server may refer to:
Microsoft SQL Server, a relational database server from Microsoft
Sybase SQL Server, a relational database server developed by Sybase
SQL Server (magazine), a trade publication and web site owned by Penton Media
Any database server that implements the Structured Query Language

Re:LOL (1)

omnichad (1198475) | about 2 years ago | (#41299149)

I think they're trying to say that Microsoft calls theirs "SQL Server" in such a way as to make it seem that the SQL standard is something they own or control.

Re:LOL (0)

hobarrera (2008506) | about 2 years ago | (#41299407)

Actually, it's called "Microsoft SQL Server".
That's just them being silly. If you follow that argument, then gnome controls the web (since their browser is just called "web" now). I could just make a file manager called "File Manager" as well.

Re:LOL (0)

Anonymous Coward | about 2 years ago | (#41299409)

You mean, idiosyncracies different from Oracle's idiosyncracies, Microsoft's idiosyncracies and IBM's idiosyncracies?

By the way, care to be specific? Oh yeah, posting anon. Right.

"GO"

I think that's all that really needs to be said.

Re:LOL (1)

RabidReindeer (2625839) | about 2 years ago | (#41300073)

Because we love to bash our keyboards into so much plastic scrap whenever we come across one of its many standards-defiant idiosyncracies?

You mean, idiosyncracies different from Oracle's idiosyncracies, Microsoft's idiosyncracies and IBM's idiosyncracies?

By the way, care to be specific? Oh yeah, posting anon. Right.

I think probably the idiosyncracy that keeps it from running on my Linux servers is probably sufficient. Although that extra level in the table naming hierarchy has been known to cause me to destroy things.

BUT THEN IT HAS ALWAYS BEEN SAYING THAT !! (-1)

Anonymous Coward | about 2 years ago | (#41294445)

So, before is was that bad, huh ?? And next time ?? Yeah, yeah, you gotta let your hair grow !!

verson 9.2 (1)

Anonymous Coward | about 2 years ago | (#41294593)

From the summary:

"9.1 adds range restricted types"

nice proof reading...

How PostgreSQL stacks up to Oracle ? (3, Interesting)

Taco Cowboy (5327) | about 2 years ago | (#41295783)

I've been searching for a comparison chart of various SQLs but all I can find are very very old articles

There's a database project that I'm working on and I'm choosing which SQL to be employed

MySQL is obviously not up to par

I don't know how good PostgreSQL is - so, is there a comparison chart or something that can facilitate us, the one who are going to make purchasing decision, to make one choice over the other?

Thank you !

Re:How PostgreSQL stacks up to Oracle ? (5, Informative)

rycamor (194164) | about 2 years ago | (#41296541)

Generally there is very little in the sense of logical data manipulation capabilities in which Oracle exceeds PostgreSQL (usually the opposite, actually). The main advantage Oracle has is in the extreme high end of scalability and replication, and that benefit is offset by massive complexity in setup and configuration. Even there, PostgreSQL is closing fast these days, with built-in streaming replication, table partitioning, and all sorts of high-end goodies.

I do all sorts of PostgreSQL consulting, and you would be surprised at the number of large companies and government organizations considering migration from Oracle to PostgreSQL.

And if you *really* need PostgreSQL to go into high gear, just pay for the commercial Postgres Plus Advanced Server from EnterpriseDB and you will get a few heavy-duty add-ons, including an Oracle compatiblity layer.

Also, IMHO one of the really cool things about PostgreSQL is the number of very geeky tools it puts at your disposal, such as a rich library of datatypes and additional features, along with the ability to create your own user-defined datatypes.

Re:How PostgreSQL stacks up to Oracle ? (3, Informative)

serviscope_minor (664417) | about 2 years ago | (#41297531)

and you would be surprised at the number of large companies and government organizations considering migration from Oracle to PostgreSQL.

Not really.

I've had no experience with the database end of things, but I've been on the receiving end of some other Oracle "products" at two places I've been. Once you've been Oracled, there is a strong incentive never to go anywhere near them again, no matter how they look on paper.

When it comes for utter distain and hatred for their customers, Oracle make Sony look like rank ametures.

As far as Oracle are concerned, the customer is a fool whose sole purpose is to be screwed over for as much cash as possible.

Re:How PostgreSQL stacks up to Oracle ? (2)

F.Ultra (1673484) | about 2 years ago | (#41297285)

Why is MySQL _obviously_ not up to par? Yes I'm really curios.

Re:How PostgreSQL stacks up to Oracle ? (1)

Anonymous Coward | about 2 years ago | (#41297985)

Their developers suck. Go look at the sort of bugs MySQL gets, AND gets AGAIN.

MySQL is the PHP of databases.

Example: http://bugs.mysql.com/bug.php?id=31001 [mysql.com]

Notice the part where the bug is reintroduced. If they require regression tests to pass before releases this bug would not happen again.

Re:How PostgreSQL stacks up to Oracle ? (2)

Lennie (16154) | about 2 years ago | (#41298859)

Lots of people such, but it is just hard to trust your data to MySQL. Just a moment ago I posted a link above to this video which illustrates it:

http://www.youtube.com/watch?v=1PoFIohBSM4 [youtube.com]

Re:How PostgreSQL stacks up to Oracle ? (1)

Nivag064 (904744) | about 2 years ago | (#41298409)

performance, reliability, ease of development...

see http://www.postgresql.org/ [postgresql.org]

PostgreSQL has had ACID compliance built in from the beginning. MySQL added it much later.

Over the last 18 years I have 3 times gone searching on the Internet for comparisons - each time PostgreSQL came out better than MySQL!

PostgreSQL is more standards compliant than MySQL, and has far fewer gotchas (unintended consequences of doing something that seemed so straightforward).

I have the misfortune to have a client with an application backed by MySQL.

Re:How PostgreSQL stacks up to Oracle ? (2)

Lennie (16154) | about 2 years ago | (#41298807)

MySQL has some nice replication built in I believe, I've never used them.

Other than that, I would thread lightly with MySQL:

"Why not MySQL"

http://www.youtube.com/watch?v=1PoFIohBSM4 [youtube.com]

That's great and all, but . . . (2, Funny)

Mitchell314 (1576581) | about 2 years ago | (#41294749)

When are they going to come out with the feature where it installs on OS X without requiring a human sacrifice? :P

Re:That's great and all, but . . . (5, Informative)

Anonymous Coward | about 2 years ago | (#41294845)

9.3. Seriously.

http://rhaas.blogspot.com/2012/06/absurd-shared-memory-limits.html

Re:That's great and all, but . . . (1)

Above (100351) | about 2 years ago | (#41295071)

What a seriously sensible and simple solution. If I could mod up, I would, but I can't so I will reply.

Re:That's great and all, but . . . (5, Informative)

dragonk (140807) | about 2 years ago | (#41295241)

I just posted this to the blog, but I will repeat it here --

There is a very good reason we OS vendors do not ship with SysV default limits high enough to run a serious PostgreSQL database. There is very little software that uses SysV in any serious way other than PostgreSQL and there is a fixed overhead to increasing those limits. You end up wasting RAM for all the users who do not need the limits to be that high. That said, you are late to the party here, vendors have finally decided that the fixed overheads are low enough relative to modern RAM sizes that the defaults can be raised quite high, DragonFly BSD has shipped with greatly increased limits for a year or so and I believe FreeBSD also.

There is a serious problem with this patch on BSD kernels. All of the BSD sysv implementations have a shm_use_phys optimization which forces the kernel to wire up memory pages used to back SysV segments. This increases performance by not requiring the allocation of pv entries for these pages and also reduces memory pressure. Most serious users of PostgreSQL on BSD platforms use this well-documented optimization. After switching to 9.3, large and well optimized Pg installations that previously ran well in memory will be forced into swap because of the pv entry overhead.

Re:That's great and all, but . . . (0)

Anonymous Coward | about 2 years ago | (#41295725)

I figure you might know. I can't find out why pSQL uses shared memory in the first place. What info I can find says "to store cached data", but what benefit does pSQL get sharing cached data with other programs? Wouldn't that be a security hole?

Re:That's great and all, but . . . (1)

ls671 (1122017) | about 2 years ago | (#41295931)

My guess is that it is only used for postgresql clusters setup, allowing different instances of postgresql to chat together as said in the blog.

Re:That's great and all, but . . . (3, Informative)

gazbo (517111) | about 2 years ago | (#41297497)

Each client connected to the DB has its own child process - the shared memory is a buffer that is shared across postgresql child PIDs with the same parent. That's why the proposed patch would work using an anonymous shared memory segment - because the memory is only passed to children of the same process.

Re:That's great and all, but . . . (0)

Anonymous Coward | about 2 years ago | (#41298161)

A process per client doesn't sound very scalable since each client would have to consume at least one thread. Ideally, any single service/application should NEVER have more threads than there are n+1 logical CPUs.

TY for the info. Lots of good responses to my question.

Re:That's great and all, but . . . (3, Informative)

gazbo (517111) | about 2 years ago | (#41298353)

Well...arguably. This is the exact same argument as Apache vs Nginx, where Apache spawns a child process per client, whereas Nginx has a limited number of worker processes that handle a queue of requests as they become free. Nginx definitely has an advantage in terms of RAM when servicing thousands of (truly) simultaneous requests.

While Postgresql does use the Apache model, there is middleware available (google 'pgpool' for an example) that amongst other things will queue requests so they can be serviced by a limited number of children. Of course this only matters if there are an awful lot of simultaneous queries (without the corresponding amount of server RAM).

However; your claim about threads per CPU is oversimplified, and especially wrong with a DB server where processes will most likely be IO bound. With 1 core, for example, there is nothing wrong with having 5 processes parsing and planning a query for a few microseconds, while the 6th is monopolising IO actually retrieving query results. Or the reverse - having 1 CPU-bound process occasionally being interrupted to service 5 IO bound processes, which would negligibly impact the CPU-bound query, while hugely improving latency on the IO bound queries.

Re:That's great and all, but . . . (1)

Anonymous Coward | about 2 years ago | (#41300253)

However; your claim about threads per CPU is oversimplified, and especially wrong with a DB server where processes will most likely be IO bound. With 1 core, for example, there is nothing wrong with having 5 processes parsing and planning a query for a few microseconds, while the 6th is monopolising IO actually retrieving query results. Or the reverse - having 1 CPU-bound process occasionally being interrupted to service 5 IO bound processes, which would negligibly impact the CPU-bound query, while hugely improving latency on the IO bound queries.

That is the old non-async model. Coroutines and async IO running one thread per CPU will dramatically increase performance under-load over one Process or thread per task.

The only work that shouldn't be done as a coroutine(co-op multi-tasking) is anything that needs guaranteed time, like management threads. But any dumb work getting done should just be part of a pool.

Well, the model I described really only works if you only care about throughput. Assuming you're IO bound and not CPU bound, latency shouldn't be an issue.

Most modern servers are IO bound well before their 32+ hardware threads get pegged.

While nginx does do many things as async, it's not a perfect design. They still use child processes and copy data via IPC, which is dramatically worse than a single process with threads.

Amdahl's law is essentially based on how much overhead is caused by resources sharing. Copying data via IPC and context switching is much worse than passing pointers and using lock-less designs. you may not see the issue under low load, but over-load a machine and watch it crumble. A properly designed program should have almost no negative scaling past 100% load. Negative scaling is what crashes servers.. that and running out of virtual memory.

Re:That's great and all, but . . . (1)

TheLink (130905) | about 2 years ago | (#41299637)

Ideally, any single service/application should NEVER have more threads than there are n+1 logical CPUs.

In the ideal world you'll never have more nonparallelizable tasks than you have CPUs.

However in the real world you often do. It is usually better for the application developers to focus on having their application solve the application related problems, and let the OS take care of the multitasking and other OS related problems.

A process per client also means that if a process crashes it is less likely to affect other clients. And if there are memory leaks for whatever weird/stupid reason, if you close that process, it frees up the mem and does not affect other processes. Compare Google Chrome and Firefox - Chrome often actually uses more memory for a given set of pages, but just close the unwanted tabs and windows and the mem is freed up, with Firefox sometimes due to plugins, bugs etc you have to close the ENTIRE browser to free up the memory. You can usually get away with having a DB process quit every now and then, but people are more likely to notice if you keep restarting the entire DB.

Of course if you do ever need 1000 or more simultaneous DB connections you probably need a different solution than a single server running plain Postgresql.

Re:That's great and all, but . . . (1)

fuzzytv (2108482) | about 2 years ago | (#41297587)

Because it's not just caching ...

Most of the shared memory is usually reserved for shared buffers, i.e. cached blocks of data files - this is something like a filesystem cache (and yes, some data may be cached twice) with the additional infrastructure for shared access to these blocks (especially for write), and so on. But there's more that needs to be shared - various locks / semaphores etc. info on connections, cluster-wide caches (not directly files) etc.

I'm not saying some of this can't be done using a page cache in Linux or something, but relying on that would make the whole database much more difficult to port to various OS (right now it has almost zero knowledge of the file system / cache beneath it). So it has pros and cons, and the pros of using shared memory outweight the cons.

Re:That's great and all, but . . . (4, Insightful)

schmiddy (599730) | about 2 years ago | (#41296533)

There is a serious problem with this patch on BSD kernels. All of the BSD sysv implementations have a shm_use_phys optimization which forces the kernel to wire up memory pages used to back SysV segments. This increases performance by not requiring the allocation of pv entries for these pages and also reduces memory pressure. Most serious users of PostgreSQL on BSD platforms use this well-documented optimization. After switching to 9.3, large and well optimized Pg installations that previously ran well in memory will be forced into swap because of the pv entry overhead.

I don't see your comment on the blog (maybe it has to be approved?), but the same issue was raised here [nabble.com] during review of the patch. The concern was mostly blown off (most PG developers use Linux instead of BSD, that might well be part of it), but if you had some numbers to back up your post, the -hackers list would definitely be interested. Ideally, you could give numbers and a repeatable benchmark showing a deterioration of 9.3-post-patch vs. 9.3-pre-patch on a BSD. If that's too much work, just the numbers from a dumb C program reading/writing shared memory with mmap() vs. SysV would be a good discussion basis.

Re:That's great and all, but . . . (0)

Anonymous Coward | about 2 years ago | (#41296727)

One could mlock() the mmap()-ed region.

Re:That's great and all, but . . . (3, Informative)

Anonymous Coward | about 2 years ago | (#41295063)

http://postgresapp.com/

Re:That's great and all, but . . . (4, Funny)

cas2000 (148703) | about 2 years ago | (#41295373)

you atheists love to take all the fun out of things, don't you?

Eliminate the human sacrifice now and next you'll be saying we have to get rid of our Steve Jobs altars.

Re:That's great and all, but . . . (2)

colinrichardday (768814) | about 2 years ago | (#41296033)

Get rid of your Steve Jobs altars!

Re:That's great and all, but . . . (-1)

Anonymous Coward | about 2 years ago | (#41295639)

When are they going to come out with the feature where it installs on OS X without requiring a human sacrifice? :P

No one gives a shit about OS X.

Re:That's great and all, but . . . (0)

Anonymous Coward | about 2 years ago | (#41297691)

You mean - http://postgresapp.com ?

Re:That's great and all, but . . . (0)

Anonymous Coward | about 2 years ago | (#41297905)

`brew install posgresql` worked flawlessly for me.

Range data types (5, Interesting)

slack_justyb (862874) | about 2 years ago | (#41295381)

I think everyone has glossed over the single most important feature in the Postgre SQL that they have refined in this release, IMHO. Ranged data types. Let's say you have a meeting schedule DB application. Well currently if you want to restrict a room between two times (start and stop) so that no one else can have the room during that time, you are going to have to write that logic in your application.

Postgre's range data type allows you to create unique checks on ranges of time. This can in two lines of code, do every single logic check that is needed to ensure no two people schedule the same room at the same time.

How this is not showing up on anyone's radar is beyond me, or maybe we all just use Outlook or Google Calendar now. However, the range types are not just limited to the application of time, but of anything that requires uniqueness along a linear fashion, as opposed to just checking to see if any other record matches the one that you are trying to insert.

Re:Range data types (0)

Anonymous Coward | about 2 years ago | (#41295615)

I'm shocked it's not already easy to do with a fairly simple constraint and two time fields.

Re:Range data types (2)

nebosuke (1012041) | about 2 years ago | (#41296087)

Strictly speaking, at minimum it would require two time fields and two boolean fields, with each boolean field specifying whether or not the interval is inclusive of each corresponding end point. It would also require a lot more than one simple constraint to get the desired behavior provided by the new datatype--and the whole mess would need to be repeated for every single interval with a simple exclusivity constraint. The new range datatype also makes it relatively simple to, e.g., specify a non-zero overlap constraint, which is significantly harder without it.

Re:Range data types (1)

stonecypher (118140) | about 2 years ago | (#41300179)

Strictly speaking, at minimum it would require two time fields and two boolean fields, with each boolean field specifying whether or not the interval is inclusive of each corresponding end point.

Yeah, or, maybe you could go look at how range fields work, and find out that that's part of the range field already.

It would also require a lot more than one simple constraint to get the desired behavior provided by the new datatype

No, actually, it wouldn't, pretend-o-saurus. It's called "an exclude constraint."

and the whole mess would need to be repeated for every single interval with a simple exclusivity constraint.

"You're wrong about this system I've never looked at because the first implementation that popped to mind wouldn't cover these obvious cases, and it's apparently beyond me that that might mean that I've guessed wrong how the feature works, instead of that you're an idiot."

Fake mode off, please.

Re:Range data types (3, Informative)

Kergan (780543) | about 2 years ago | (#41297227)

Oh, it's simple enough to do with two separate fields and a check constraint. That's how you'd do it i other DB engines, in fact.

Ensuring there are no overlaps is an entirely different story, however: queries against those two fields cannot make any reasonable use of an index. The ranged type, by contrast, allows you to query the data using a nearest neighbour search and a GiST index.

Think of a GiST index as indexing the smallest boxes that enclose your shapes of interest. When queried, the DB scans for boxes that overlap your box of interest, and discards rows that don't match the data's actual shape.

Re:Range data types (0)

Anonymous Coward | about 2 years ago | (#41295827)

> Well currently if you want to restrict a room between two times (start and stop) so that no one else can have the room during that time, you are going to have to write that logic in your application.

So you want to do that in the DB now. Will you have to change column definition to change that range? For example, somebody already booked several hours in that room. I can see range feature can be useful but don't see relationship to your scheduling example.

Re:Range data types (2)

nebosuke (1012041) | about 2 years ago | (#41295997)

It seems that you're misunderstanding the definition of a range datatype in this context. The data type of the column in the scheduling example would be defined as a timestamp range, and the constraint on the column would be that no timestamp range value can overlap with any other timestamp value in the table (or in the table for any rows that share a key value, such as user ID). There is no need to alter the column definition to accomodate changes to scheduling data.

Re:Range data types (2)

DragonWriter (970822) | about 2 years ago | (#41299285)

So you want to do that in the DB now. Will you have to change column definition to change that range?

No, the range is data, not part of the column definition, I would say "RTFA", but to be fair the link was mislabelled in TFS as being about "range-restricted types", rather than range types.

But here's the docs on range types [postgresql.org] . The scheduling use case is the basic example of exclusion constraints on range types (Sect 8.17.10 in the linked doc.)

Re:Range data types (1)

DragonWriter (970822) | about 2 years ago | (#41299213)

I think everyone has glossed over the single most important feature in the Postgre SQL that they have refined in this release, IMHO. Ranged data types.

TFS apparently (from the link, which goes to range datatypes) meant to refer to them when it made the comment about "range-restricted datatypes".

Postgres-Curious (4, Interesting)

kwalker (1383) | about 2 years ago | (#41295397)

TL;DR: Is there an advanced PostgreSQL for MySQL Users guide out there somewhere? Something more than basic command-line equivalents? And preferably from the last two major releases of the software?

Long version
I've been using MySQL personally and professionally for a number of years now. I have setup read-only slaves, reporting servers, multi-master replication, converted between database types, setup hot backups (Regardless of database engine), recovered crashed databases, and I generally know most of the tricks. However I'm not happy with the rumors I'm hearing about Oracle's handling of the software since their acquisition of MySQL's grandparent company, and I'm open to something else if it's more flexible, powerful, and/or efficient.

I've always heard glowing, wonderful things online about PostgreSQL, but I know no one who knows anything about it, let alone advanced tricks like replication, performance tuning, or showing all the live database connections and operations at the current time. So for any Postgres fans on Slashdot, is there such a thing as a guide to PostgreSQL for MySQL admins, especially with advanced topics like replication, tuning, monitoring, and profiling?

MariaDB and Percona (3, Insightful)

kbahey (102895) | about 2 years ago | (#41295641)

Oracle is not that big a of concern.

There is MariaDB [mariadb.org] which is data-compatible with MySQL, and has some nice additions (like microsecond performance data), and there is also Percona Server [percona.com] .

If Oracle messes up, like they did with OpenOffice, there will be another version that they cannot touch, like LibreOffice.

Re:Postgres-Curious (0)

Anonymous Coward | about 2 years ago | (#41295705)

The "new" replication thingy in postgresql 9.x is ... new. You need to wait a bit for those HOWTO guide.
But the official documentation is complete, it contain everything you needs.

Re:Postgres-Curious (4, Informative)

Art3x (973401) | about 2 years ago | (#41295959)

PostgreSQL replication is new (revision 9.1) so there may be little out there (Yes, there was replication, but with additional software, like Slony).

I'm in the weird position of having used PostgreSQL mainly --- for seven years, writing dozens of applications --- but never MySQL. I've also used --- out of necessity only --- Microsoft SQL, Oracle, and Ingres, and PostgreSQL is much better. Just from a programming point of view, the syntax is, in my mind, simpler yet more powerful --- more ANSI-SQL-compliant, too, I've heard.

Anyway, the point is, I've never used anything I like more. I adore PostgreSQL. It's so powerful. So many useful datatypes, functions, syntax. Not to mention it's ACIDity.

To your question, though --- are there any good books to help a MySQLite move to PostgreSQL? Not that I've come across. But then again, I haven't found any good PostgreSQL books --- or even, for that matter, very well-written SQL books, period. They all are stupefyingly boring --- but I got what I could out of them.

Actually, PostgreSQL's documentation is not that bad. In particular, try sections I, II, V, VI, and III, in that order. Skip anything that bores you at first. You can always come back. Honestly, there can't be that much of a learning curve for you, coming from MySQL.

Re:Postgres-Curious (2)

poet (8021) | about 2 years ago | (#41296221)

9.0 was the first version with replication, not 9.1 and we have had things like warm standby since 8.1.

Re:Postgres-Curious (2)

gullevek (174152) | about 2 years ago | (#41296359)

There are two PostgreSQL books I used a lot in the past: PostgreSQL 9.0 High Performance by Gregory Smith (Packt) and PostgreSQL Second Edition by Douglas Douglas (O'Reilly).

There is an extended list of books listed on the PostgreSQL homepage: http://www.postgresql.org/docs/books/ [postgresql.org]

Problem with all books is, they get outdated too quickly. While a lot of the basic info is still true for the books above, the O'Reilly book is very much based on 8.4 with is pretty ancient already. Perhaps getting an ebook is less a waste of paper.

Re:Postgres-Curious (1)

aralin (107264) | about 2 years ago | (#41296923)

If you look for a good SQL programming book, the PL/SQL book from Oracle is the best book written in this area, IMHO. As for the MySQL to PostgreSQL book, there was no incentive to write it for PostgreSQL power users. We mostly looked over the time at MySQL as toy database and it's users as at best misguided and at worst, not caring about data integrity (cardinal sin in my book). So writing such book would be sort of like "Black Hat Hacking for Script Kiddies". Sure it could be done, but who wants a bunch of amateurs crowding their field? Next thing you know, they will ask for bugfix to treat NULL like zero. :)

Re:Postgres-Curious (3, Informative)

fuzzytv (2108482) | about 2 years ago | (#41297673)

Well, recommending a PL/SQL book as a source for learning SQL is a bit silly IMHO. Moreover, I find the books from Oracle rather bad - there are better sources to learn PL/SQL (e.g. the one from Feuerstein is a much better book).

And in fact there's a great book about administering PostgreSQL from Hannu Krosing - it's called "PostgreSQL 9 Admin Cookbook" [http://www.packtpub.com/postgresql-9-admin-cookbook/book]. It's a great set of recipes for admins for common tasks, not an exhaustive documentation (that's what http://www.postgresql.org/docs/9.1/interactive/index.html [postgresql.org] is for), but if you want to learn how real pros admin the database, this is the right choice. And yes, I'd recommend it to newbies coming from MySQL.

It might seem that the PostgreSQL community considered MySQL to be a toy database in the past, but it definitely was not a generally shared view. And this definitely changed recently - there's no reason not to join the community mailing lists / IRC channel and start a post with "I'm using a MySQL right now and I don't understand why PostgreSQL does SOMETHING."

Re:Postgres-Curious (0)

Anonymous Coward | about 2 years ago | (#41298101)

Isn't that like suggesting a javascript book for a java progammer? (or vice versa..)

Re:Postgres-Curious (1)

omnichad (1198475) | about 2 years ago | (#41299399)

I have to admit, as a long-time MySQL user, it really messes with your head and makes you not do things in a way that works with MS SQL Server or PostgreSQL. Especially how MySQL does its lazy grouping.

I've only tried other databases for a short while and give up because I know that I'd have to learn everything properly. If I was starting a brand new project, it might be great, but I wouldn't want to rewrite an existing database app with it.

Re:Postgres-CurioPostgres comes with great documus (0)

Anonymous Coward | about 2 years ago | (#41295991)

You might want to just read the Postgres documentation. It's very well written.

Re:Postgres-Curious (0)

Anonymous Coward | about 2 years ago | (#41296419)

Native replication is a fairly recent addition to Postgresql. It is definitely one thing that MySQL has better options with. From a tech talk I listened in on, online, it just seemed kludgey. It seemed to me the way Postgres does logging makes it a little more challenging. I like Postgres for all its other strengths and use it, but they should focusing on things like replication, materialized views, and other more core business friendly features. I think it will be a few more releases before people won't have to rely on third party software for serious high availability stuff. I say this only because I expected it to be a major feature of this release since it is still relatively new and had a way to go when first released. I sure hope they don't think they have something that is actually good for serious work in that regard.

Re:Postgres-Curious (1)

fuzzytv (2108482) | about 2 years ago | (#41297717)

What's wrong with third-party stuff? I mean, looking bad it was silly to expect this to happen with replication (third-party replication solutions, not included in the core), but with the management tools this should not be a problem - there are already tools like repmgr and more to come. The problem with in-core tools is that they hard-code a single way to do things the release cycle is tightly bound to the PostgreSQL itself and it's a significant effort for the whole community.

Regarding the replication - it's still a relatively new feature (although two years is a long time), so it has some rough edges, but I wouldn't call it kludgey at all. It's very nicely thought-out and crafted feature. Once you get an idea of how it works / how to set it up, it's fairly simple to do that again and even write a bunch of simple scripts to manage it.

And yeah, there are many features we'd like to see in PostgreSQL, but the community simply has a limited manpower and it's using it to satisfy the main needs of it's current users. It's not that the community strives to beat all the other databases - the goal of the community is to provide useful features for it's users.

Re:Postgres-Curious (4, Informative)

rycamor (194164) | about 2 years ago | (#41296595)

Unfortunately, I haven't found a really good guide of the type you are looking for. I can give you my experiences, going from MySQL to PostgreSQL, back to MySQL to support it at a large company, and then back to PostgreSQL. Generally, these days there is really *nothing* that I can find about MySQL that can't be done better in PostgreSQL. I mean it. At least for awhile MySQL could boast of native replication, but Postgres biw has that and it is arguably much more robust than MySQL's solution (had the misfortune to support MySQL replication for 2 years). Ditto with full-text indexing, and just about any other MySQL feature.

Main differences:

1. PostgreSQL is much more "correct" in how it handles data and has very little (essentially no) unpredictable or showstoppingly odd behavior of the sort you find in MySQL all the time. Your main problem in migrating an app to PostgreSQL will be all those corner cases that MySQL just "accepts" when it really shouldn't, such as entering '0000-00-00' into a date field, or allowing every month to have days 0-31. In other words, PostgreSQL forces you to be a lot more careful with your data. Annoying, perhaps, if you are developing a non-mission-critical system like a web CMS or some such, but absolutely a lifesaver if you deal with data where large numbers of dollars and cents (or lives) depend on correct handling.

MySQL has provided for a fair amount of cleanup for those who enable ANSI standard behavior, but it is still nowhere close to PostgreSQL's level of data integrity enforcement.

2. MySQL has different table types, each of which support different features. For example, you cannot have full-text indexing in InnoDB (transactional) tables. PostgreSQL has complete internal consistency in this regard.

3. MySQL has an almost entirely useless error log. PostgreSQL's can be ratcheted up to an excruciating level of detail, depending on what you want to troubleshoot. Ditto with error messages themselves.

4. MANY MANY more choices in datatypes and functions to manipulate them. Definitely a higher learning curve, but worth it for expressive capability.

5. Don't get me started on performance. Yes, if you have a few flat tables, MySQL will be faster. Once you start doing anything complicated, you are in for a world of pain. Did you know that MySQL re-compiles every stored procedure in a database on every new connection? PHP websites with per-page-load connections can really suffer.

6. Don't get the idea that PostgreSQL is more complex to work with. If you want simple, you can stick with the simple parts, but if you want to delve into complex database designs and methodologies, PostgreSQL pretty much opens up the world to you.

- Glad to be back in the PostgreSQL world...

Re:Postgres-Curious (1)

Jay L (74152) | about 2 years ago | (#41296829)

Greg Smith's book "High-Performance SQL" is a good start.

Re:Postgres-Curious (1)

fuzzytv (2108482) | about 2 years ago | (#41297645)

No, I'm not aware of such thing ("PostgreSQL for MySQL people" style guide).

The best thing you can do is give it a ride - install it, use http://www.postgresql.org/docs/9.1/interactive/admin.html [postgresql.org] to do the setup etc.

Basically all you need to do to install and start the PostgreSQL from source code is this (at least on Linux):

$ cd postgresql-9.1.5
$ ./configure --prefix=/path-to-install
$ make install
$ export PATH=/path-to-install/bin:$PATH
$ pg_ctl -D /database-directory init ... fiddle with the config at /database-directory/postgresql.conf
$ pg_ctl -D /database-directory -l /database-directory/postgresql.log start

and then

$ createdb testdb
$ psql testdb

and you're in. If you're installing that from a package (e.g. RPM in RedHat), it might work a bit differently - depends on the packager.

Anyway, use the project mailing lists and IRC channel - there's always someone ready to help / answer novice or complex questions etc.

Re:Postgres-Curious (1)

Anonymous Coward | about 2 years ago | (#41298355)

Read the PostgreSQL docs.

Unlike MySQL, their docs are clear, complete and exhaustive. The MySQL docs require you to read user comments on the documentation to learn how the software actually works.

Not the case here, PostgreSQL's design and behavior is clearly and properly documentated

meh (-1, Flamebait)

kelemvor4 (1980226) | about 2 years ago | (#41295525)

Wake me when it catches up with MemSQL.

Re:meh (1)

Tough Love (215404) | about 2 years ago | (#41295589)

Wake me when it catches up with MemSQL.

That would have to be called MemgresQL, wouldn't it.

Re:meh (1)

fuzzytv (2108482) | about 2 years ago | (#41297753)

Could you please compare Ferrari F1 and Liebherr T1-272 minin truck [e.g. http://www.flickr.com/photos/doncampbellmodels/3434490464/%5D [flickr.com] ? Not possible, right? Different products for different requirements.

Re:meh (1)

fuzzytv (2108482) | about 2 years ago | (#41297761)

Damn, this was supposed to be a response for the parent flamebait ...

Re:meh (2, Insightful)

Anonymous Coward | about 2 years ago | (#41295695)

Wake me when MemSQL supports data-warehousing.

Re:meh (1)

Nivag064 (904744) | about 2 years ago | (#41296559)

Your comment reminds me about a pregnant woman who phoned her doctor saying she had contractions - her doctor said come in when they get to 3 minutes apart - when she phoned a while later saying they were still only a minute or so apart, she was told to come in immediately! You might find that PostgreSQL is already in advance of 'MemSQL'!

More seriously, unless you say what features you think MemSQL is ahead off PostgreSQL, you are sounding very much like a troll.

The appropriate database software depends very much on the specific use case, for most real world requirements you are likely to find PostgreSQL a good choice.

comment (0)

Anonymous Coward | about 2 years ago | (#41295961)

Was the scalability that bad to begin with ?

JSON (2)

Art3x (973401) | about 2 years ago | (#41296069)

To me, JSON very interesting. I don't know how exactly I'll use it, but it combines all that's great about PostgreSQL with some of what was interesting about CouchDB and other projects like it.

Mainly, one-to-many relationships may be easier. Usually, they are two separate select statements. For example, one to get the article, another to get the comments. Then you patch it all together in PHP, or whatever middle language you're using. With JSON support, that could be a single SELECT, crammed up in JSON, which you then uncram with a single json_decode function call in PHP, which would yield nice nested arrays.

Re:JSON (1)

Anonymous Coward | about 2 years ago | (#41296225)

I think you just made the database fairies cry.

Re:JSON (1)

Anonymous Coward | about 2 years ago | (#41296501)

Then you defiantly don't want to see the DB tables I've seen with just a primary key and a single XML field, then add on XPath indexes.

Re:JSON (1)

DragonWriter (970822) | about 2 years ago | (#41299449)

Mainly, one-to-many relationships may be easier. Usually, they are two separate select statements.For example, one to get the article, another to get the comments. Then you patch it all together in PHP, or whatever middle language you're using.

I'm not sure adding new SQL features is going to deal with the problem of people not using the features they already have. Its already quite possible in PostgreSQL to do a single select that gets the article data and an aggregate that contains all the comments. Features that let you store JSON directly aren't necessary for that.

While Postgres is good for many things... (2)

FlyingGuy (989135) | about 2 years ago | (#41296335)

Until the fix the TX number issue ( the infamous rollover ) then they are pretty much out of the running in DB's that have VERY high insert levels since the vacuum process cannot hope to keep up with tables that have 100's of millions of rows.

I am an Oracle professional but I do keep track of Postgres and like it, but the 32 bit TX t is a bit of an Achilles heel.

Re:While Postgres is good for many things... (2)

Anonymous Coward | about 2 years ago | (#41296443)

you can't vacuum your table every 2 billion transactions? did you know autovacuum exists?

There is no table with "100's of millions of rows" that can't be vacuumed every 2 BILLION transactions.

http://www.postgresql.org/docs/current/static/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND

Re:While Postgres is good for many things... (1)

FlyingGuy (989135) | about 2 years ago | (#41296479)

hmmmm table with 17 trillion rows? Not so much.

Re:While Postgres is good for many things... (0)

Anonymous Coward | about 2 years ago | (#41296505)

vacuum does not lock the tables, so there's no down time associated. so what exactly is the problem with letting autovac run every 2 billion transactions?

Seriously I would like to know.

Re:While Postgres is good for many things... (0)

Anonymous Coward | about 2 years ago | (#41296635)

and BTW, 2 billion is the recommendation. data loss does not occur until you reach 4 billion.

Re:While Postgres is good for many things... (0)

Anonymous Coward | about 2 years ago | (#41298221)

what exactly is the problem with letting autovac run every 2 billion transactions?

Only weak cranes ask this question.

Re:While Postgres is good for many things... (1)

Anonymous Coward | about 2 years ago | (#41299209)

If you have a single table with 17 trillion rows then you're doing it wrong. And inserts aren't really an issue with MVCC in PG - I'd focus more on updates.

Partitioning in PostgreSQL will let you split that up into separate physical items on disk. As others have said - you just need to let vacuum scan the table once every 2 billion transactions or so to keep things in check. Rows that aren't update regularly will be given the special frozen xid and won't be subject to any wrap around issues.

And as far as databases hitting this limit are concerned - not an issue - PG will shut down ~ 2 million transactions before that limit until you do something about it. On fast hardware you can recreate the table in no time. I can, with some degree of embarassment, admit to letting a DB get to this point because I hadn't tuned the various parameters around vacuum. Fixed that fairly quick smart let me tell you and its been humming since.

Oracle is legacy software at best these days - even in the traditional shops such as banks - leave the next wave to the new boys that are receptive to what developers want and customers need.

- maintainer of 200+TB of PostgreSQL databases.

Re:While Postgres is good for many things... (1)

rycamor (194164) | about 2 years ago | (#41299287)

Yes, there are all sorts of interesting strategies you can employ once you separate the physical storage from the logical presentation... can't be said enough.

Re:While Postgres is good for many things... (0)

Anonymous Coward | about 2 years ago | (#41298365)

that have VERY high insert levels

Unless you also have VERY high delete levels, vacuum is going to be almost a no-op. If you disable automatic table analysis, vacuum will have nothing at all to do on the table other than update the frozen tid.

Re:While Postgres is good for many things... (1)

LizardKing (5245) | about 2 years ago | (#41298861)

Until the fix the TX number issue ( the infamous rollover ) then they are pretty much out of the running in DB's that have VERY high insert levels since the vacuum process cannot hope to keep up with tables that have 100's of millions of rows.

Infamous to whom? A vacuum updates the frozen TID, which is a trivial operation and allows a subsequent TID to safely wrap around. And I'm struggling to think of any common use cases where the volume of inserts is so high that they can't afford a vacuum every two billion transactions - even high-frequency trading doesn't operate at those levels, and if it did I suspect TID wraparounds would not be your most pressing concern.

Re:While Postgres is good for many things... (1)

TheLink (130905) | about 2 years ago | (#41300395)

A vacuum updates the frozen TID, which is a trivial operation and allows a subsequent TID to safely wrap around.

What if you have at least one outstanding transaction/connection? Can vacuum update the frozen TID then?

For example if you have a transaction that's open for a few weeks and happen to have 4 billion transactions during that time.

I believe perl DBI/DBD in AUTOCOMMIT OFF mode starts a new transaction immediately after you commit or rollback. So if you have an application using that library that is idling for weeks a transaction would presumably be open for the entire time- since it would be connected to the database and already have started a transaction. This is probably also true for some python and ruby db libraries.

This could also happen if someone starts up psql, starts a transaction and goes on vacation ;).

Still no checksums? (0)

Anonymous Coward | about 2 years ago | (#41296725)

Wasn't support for checksums meant to _finally_ get into 9.2? Postponed again?

PostgreSQL is so cool (1)

DrXym (126579) | about 2 years ago | (#41297425)

It just works properly out of the box. No nasty surprises, no alarming omissions or deviations from expected database behaviour. It's just a fast, reliable database which also happens to be open source and free.

I'm sure most of this applies to MySQL these days but historically it didn't and I never saw the attraction of a DB which went through a succession of backends in order to obtain the behaviour PostgreSQL always supplied. It doesn't help that MySQL is Oracle owned and all the issues with licencing and forking which have arisen out of that.

Re:PostgreSQL is so cool (1)

Lennie (16154) | about 2 years ago | (#41299997)

I believe they both improved.

PostgreSQL 7.x wasn't as much fun either which didn't have autovacuum and needed a lot of tuning.

I haven't tried something like Drizzle but it seems they ditched a lot of old code and problems.

Range types -- not range-restricted -- are major (2)

DragonWriter (970822) | about 2 years ago | (#41299167)

Minor, but probably a welcome relief to those who need them, 9.1 adds range restricted types.

First, its 9.2, not 9.1.

Second, (as shown in the link) these are range types, not range-restricted types. Range-restricted types (as known from, e.g., Ada) are something that (via domains with check constraints) PostgreSQL has supported for a very long time.

Range types, combined with 9.2s support for exclusion constraints, are a pretty major new feature that give 9.2 a great facility in dealing with (among other things) temporal data and enforcing common logical constraints on such data in the database as simple-to-express constraints rather than through triggers.

Load More Comments
Slashdot Login

Need an Account?

Forgot your password?
or Connect with...

Don't worry, we never post anything without your permission.

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>