This talk explored a bit that idea, you could have a (full) programming language which is more like SQL so you get good enough datastructures (and indexing- without manual tuning: https://www.youtube.com/watch?v=gC295d3V9gE
I think Prolog (another commenter pointed it out) and datalog do this to some extend.