8 ms·
I've dived into the postgres code recently and it was incredible. Lisp legacy is all over the place, it's literally lisp in C, though unlike many "Langname-styl
by ernst_klim 8y ago
I've dived into the postgres code recently and it was incredible. Lisp legacy is all over the place, it's literally lisp in C, though unlike many "Langname-styled C" codebases it looks really clean and organic.
I'm still confused how people prefer oracle [1] other postgres.
[1] https://news.ycombinator.com/item?id=18442941 https://news.ycombinator.com/item?id=18442941
- jstimpfle 8y agoWhat is "Lisp style C"? Can you link an example?
- nicklaf 8y agoI can't find it, but I remember seeing a linked list library for C, which supported a functional style like Lisp. I don't know how closely it was related to S-expressions, but I'd be interested if somebody could help me remember what I'm thinking of here.
- mschaef 8y agoI tend to think of George Carette's SIOD Scheme interpreter when I think of "Lisp style C": LISP difference(LISP x,LISP y) {if NFLONUMP(x) err("wta(1st) to difference",x); if NULLP(y) return(flocons(-FLONM(x))); else {if NFLONUMP(y) err("wta(2nd) to difference",y); return(flocons(FLONM(x) - FLONM(y)));}} http://people.delphiforums.com/gjc/siod.html http://people.delphiforums.com/gjc/siod.html Of course, that's a Scheme interpreter, so it might be at least a little expected.
- hildaman 8y agoI'll tell you why - try to update one column in 100GB worth of row data. Postgress makes a copy of _every_ row and you need 100GB of extra space on the hard-drive until you commit the transaction. Now extrapolate to a 1TB table that needs updating. Oracle has a way of doing this w/o copying the entire row.
- snuxoll 8y ago> Postgress makes a copy of _every_ row and you need 100GB of extra space on the hard-drive until you commit the transaction. This only happens if the column is indexed, heap-only-tuples will allow in-place updates otherwise. This doesn't dismiss it as a potential problem entirely, but depending on your needs you may never run into this.
- djd20 8y agoI would argue thats an issue with your architecture at that point - you may want to use table partitioning at sizes that big, or have some other mechanism in place to be able to lock access while updating such large data sets in one go.
- snuxoll 8y agoI would generally agree, though there are unfortunately limitations imposed on you the moment you start using partitioning with PostgreSQL (foreign keys remain to be a big one).
- nly 8y agoSo what's the workaround? Drop the index, update, then re-establish the index?
- gopalv 8y ago> Postgress makes a copy of _every_ row That's what the zHeap storage engine for Postgres fixes - in-place updates for fixed width data. https://github.com/EnterpriseDB/zheap https://github.com/EnterpriseDB/zheap
- polskibus 8y agoOracle like many other databases has clustered indexes. PostgreSQL does not and it can have big performance implications.
- mmaurizi 8y agoAre you sure about that? https://www.postgresql.org/docs/9.1/sql-cluster.html https://www.postgresql.org/docs/9.1/sql-cluster.html
- polskibus 8y agoThat's not how a real clustered primary key works, because "the changes are not clustered.".
- asah 8y agocan confirm. That said, one can often capture much of the performance benefit with Postgres indexes - basically, instead of trying to tightly-pack the base tables, copy the data into indexes which are tightly packed exactly as you need. Put another way, Postgres indexes are synchronously updated materialized views - and yes, the Postgres planner/optimizer will automatically answer queries from an index if it's faster and all the columns are in there. I esp recommend reading about function and expression indexes, as well as the (new) covering indexes. http://blog.scoutapp.com/articles/2016/05/31/3-postgresql-indexing-tricks-that-surprise-everyone http://blog.scoutapp.com/articles/2016/05/31/3-postgresql-in... https://www.endpoint.com/blog/2013/06/10/postgresql-functional-indexes https://www.endpoint.com/blog/2013/06/10/postgresql-function... https://paquier.xyz/postgresql-2/postgres-11-covering-indexes/ https://paquier.xyz/postgresql-2/postgres-11-covering-indexe...
- polskibus 8y agoSurely the writes will be much slower if you have to copy the data to the index
- 8y ago
- diminoten 8y agoHave you tried to scale horizontally with Postgres?
- outworlder 8y agoHave you tried to scale horizontally with Oracle?
- spapas82 8y agoBecause "nobody was fired for choosing oracle" https://www.google.com/search?hl=en&q=hackernews%20nobody%20was%20fired%20for%20choosing%20oracle https://www.google.com/search?hl=en&q=hackernews%20nobody%20...
- kazinator 8y agoI'm taking a look at this now and can't make the same conclusion. For instance, the "bag-like" List and ListCell stuff is completely non-Lispy: https://github.com/postgres/postgres/blob/master/src/backend/nodes/list.c https://github.com/postgres/postgres/blob/master/src/backend... Mind you, I'm biased because I've written a fair amount of actual "Lisp style C", e.g.: http://www.kylheku.com/cgit/txr/tree/regex.c?id=2938a0d7e64e2adad3db0988689635e81ad91739#n1981 http://www.kylheku.com/cgit/txr/tree/regex.c?id=2938a0d7e64e... My detector for "this C is Lispy" has a rather high threshold / low gain.
- neilc 8y agoYeah, we replaced the old Lisp-style List implementation with a different implementation a while ago: https://github.com/postgres/postgres/commit/d0b4399d81f39decccb23fa38f772b71b51bf96a https://github.com/postgres/postgres/commit/d0b4399d81f39dec... You can still see the Lisp heritage in a few places, but overall I wouldn't say Postgres is "literally lisp in C".
- agumonkey 8y agoYou should host teachings in college and schools.
- kazinator 8y agoI see that this diff contains a lot of fluff: in many places, functions and variables are changing names while the code which uses them remains the same. In code that truly embraces "Lispy" lists, you cannot switch to an encapsulated list representation without making substantial changes to the code. For instance if you have any cdr recursion going on, that will have to be restructured, because a bag-style list doesn't have a cdr that is itself a bag-style list. (Perhaps the function has to be split into an external one that takes the List and then a local recursive part that works with the ListCell.) I would say that to a fair extent, it looks to me as if the code anticipated a future retargeting to a different list representation, whereas the "Lispy" approach is to embrace a particular list representation. Lisp programs sometimes need to improve the performance of adding to the tail of a list; it's done with some wrapping, like a structure that keeps a pointer to the tail. Usually that is only locally used; it doesn't "travel" as part of the representation of the list. It is not an encapsulation device, but only a process device. Of course there is also the common pattern of building up a list in reverse followed by a destructive nreverse. And the meta-approach of designing things to avoid doing work at the tail end of the list. I just remembered the existence of some C code that has nothing to do with any Lisp implementation internals, which pushes and nreverses: http://www.kylheku.com/cgit/c-snippets/tree/autotab.c#n228 http://www.kylheku.com/cgit/c-snippets/tree/autotab.c#n228 A double-ended queue (deque) can be formed in Lisp by using a pair of lists. So both ends of the queue are list heads, from which we cdr into the interior. I developed such a thing which is hosted here: http://www.kylheku.com/cgit/lisp-snippets/tree/deque.lisp http://www.kylheku.com/cgit/lisp-snippets/tree/deque.lisp With this deque, we simply use the push macro to add items to either end of the queue. pop-deque will remove an item from either end. Underflows are handled by rebalancing the dequeue: shuffling items from one list to the other. The cost of that is amortized. (BTW I see that pop-deque has a multiple-evaluation-of-arguments problem; it really should be written using get-setf-expansion.)
- paulie_a 8y agoI'm confused why anyone prefer Oracle at all. You can basically swing a bat at their codebase and default creds come raining down. Everything they touch has a steroid infused YOLO.
- PaulHoule 8y agoPostgres has led the world in trash-talking other databases for 22 years. I used to call it CrashGreSlow back when Mysql was maintained. Postgres had a manifesto which trash-talked Oracle but it was not a reliable product at that time. Maybe the people who said it was fast were running it on ram disks with fsync turned off or something. After mysql got bought by Sun and put on ice, postgres caught up with the hype and now it is pretty reliable. That wasn't always the case.
- threeseed 8y agoSeriously though this is true especially from their users. It is never just PostgreSQL is a great database. It’s always that MySQL, Oracle, MongoDB and the hundreds of NoSQL databases are all unusable junk with no unique benefits.
- weberc2 8y agoI've never heard this, but I don't know any hardcore database folks either. Mostly it's just "I need a SQL database for my application and Postgres seems to be a good default" (note that I mostly roll with a Linux/Unix crowd, otherwise it'd probably be the same thing except s/Postgres/SQLServer).
- PaulHoule 8y agoOracle is OK if you can afford it and afford a nice battery backed storage array that (truthfully) fsyncs quickly. MongoDB is crap. I think the people who use Arangodb don't talk about it because they see it as a competitive advantage. Right now I am working on an abstraction layer for document databases and using couchdb side by side with Arangodb. I guess I'll have to write a N1QL parser to go with my AQL parser. The database I have the most fun with is SQLite. It is single-user, which means you can't log in with the SQL monitor when your program is running, but if you can accept that it's just great.
- gtsteve 8y agoMySQL is still under development, and there are numerous forks. I use it for my company; it's still a very good database option, albeit perhaps a little basic. However the fact that it's owned by Oracle does make it a little bit scary, even though we have no exposure to their code or anything linked at all. I sort of wish we'd chosen Postgres instead.
- irrational 8y agoSeriously. After using Oracle for 15+ years, moving to Postgres has been amazing. Just moving from clob to text has nearly brought me to tears of happiness. Nearly all of our complex sql queries are simpler in postgres. The documentation is light years better.
- sdegutis 8y agoLegacy code + Enterprise = a life so long it feels like butter spread a little too thin over toast, as Bilbo Baggins put it.
- SilasX 8y agoI don't think anyone "prefers" Oracle; it just persists on some combination of politicking, inertia, vendor lock-in, and contracts that assure regulatory compliance.