News for hackers. Stuff that matters.
Re:Why use a database instead of just saving your data to disk? by wildgift on Sunday May 19, 2013 @06:36PM (#5734695)
I never thought of SQL as declarative or like Prolog. I think it's more like a filter-writing language, with set functions like join.

Agreed that the distance between Lisp and SQL is a lot shorter so an RDMBS doesn't gain you very much. In functional languages, it's normal to write filters and apply functions to lists. You also end up performing your joins manually, and end up "optimizing the query" as you code.

In SQL, filters and apply (update) are easier to write, but it's also easy to perform a join that is slow.

Re:Why use a database instead of just saving your data to disk? by ksherlock on Sunday May 19, 2013 @10:40PM (#5735536)
Try reading up on relational calculus (and relational algebra). You may find it enlightening
Re:Why use a database instead of just saving your data to disk? by ucee054 on Sunday May 19, 2013 @08:10PM (#5735045)
I never thought of SQL as declarative or like Prolog.

Look at the different forms of relational calculus (SQL is intended to be basically syntactic sugar on top) or look at some research papers by Fariba Sadri - hell, look at the earliest papers on relational databases by EF Codd. RDBMSs were meant to be logic systems right from the start.

it's also easy to perform a join that is slow

Have you been using MySQL? Use a real database with a working query optimizer eg I know from experience that MS SQL will do its best even when you give it a dog of a query. For example it will re-arrange your "filter" and build a temporary index to make your join go at the fastest possible speed.

If you have a specific use case nailed down you can always make it go faster outside of an RDBMS much the same way that you can always make something go faster if you hand-code it in machine code instead of using a compiler.

But if you can't put that much effort into hand-optimizing things, say because your use case might change so you'd have to change the code, the query optimizer/compiler will do a better job.