341 points · by prawn · 11y ago · 44 comments
http://xoph.co/20130917/mandelbrot-sql/
Of course, it comes with a hefty dose of proprietary functionality. I think the newer versions of Oracle support recursive CTEs -- but fortunately, I don't have to deal with Oracle any more, so it's dead to me ;)
I recently did a project where I got to use Oracle 12c. Bit of a hump getting back into it (last time I used Oracle was 8 in the early 2000s), but, man, it is amazing what you can do with it when you leverage all of its power.
I really hope they adjust their pricing model in the future to be friendly to non-billion-dollar corporations -- I'd love to use Oracle as the foundation for a startup, because the technology is decades ahead of where open source is, but, man, $48k/core... that's rough.
https://wiki.postgresql.org/wiki/Mandelbrot_set
"This SQL query (requires PostgreSQL 8.4) produces an ASCII-art image of the Mandelbrot set. It is written entirely in SQL:2008-conformant SQL."
Fun thing to do, put this in a `.ps` file and send it to a printer. Should think for a bit and then print a mandelbrot:
%!PS-Adobe-2.0 51 .5 551 { /x exch def 111 .5 721 { /y exch def y 521 sub 201
div x 301 sub 201 div 1 index 1 index 31 -1 1 { /n exch def 1 index dup mul 1
index dup mul 1 index 1 index add /d exch def sub 4 index add 3 1 roll 2 mul
mul 2 index add d 4 gt {exit} if } for pop pop pop pop n 31 div setgray x y
moveto .5 0 rlineto 0 .5 rlineto -.5 0 rlineto fill } for } for showpage
I had a TSQL one as well, not mine though: https://www.growse.com/2009/05/01/odd-ways-of-making-a-mande...[1] http://mirror.switch.ch/ftp/mirror/tex/graphics/pgf/base/doc... Page 696
http://www.andreas-dewes.de/en/2015/queens-of-the-data-age-a...
As others have pointed out there is a really nice section on CTEs in the SQLite documenation as well:
[0] http://explainextended.com/2013/12/31/happy-new-year-5/
[1] http://www.postgresql.org/docs/9.0/static/functions-geometry...
After that, we move on to Zawinskie's law.
I'll leave the proof to interested readers.
https://wiki.postgresql.org/wiki/Category:Fun_Snippets
The Mandelbrot is awesome, but the pie chart is some next level stuff. You can even make it colored.
The code on the left is SQL, normally used to query databases, but in this case is being used to create the image on the right.
This is impressive because SQL isn't generally thought of as a language for arbitrary computation.
it would be very impressive, if postgresql could generate it's own CRUD interface (select option: angular / react)
so much tedious frame-work could be just dropped.
"PostgREST serves a fully RESTful API from any existing PostgreSQL database. It provides a cleaner, more standards-compliant, faster API than you are likely to write from scratch."
Sidenote: Anyone had any experience using postgrest? Any good?
Probably don't use it in production.
I assume one could do the same by having it generate html and javascript.
Note that could != should.