5 ms·
Brute force search is just the naive way of finding solutions. Just like you can index a SQL table, you can index a Prolog predicate for better performance.
by simplify 2y ago
Brute force search is just the naive way of finding solutions. Just like you can index a SQL table, you can index a Prolog predicate for better performance.
- sterlind 2y agoYou can index, but iirc Prolog's indexing isn't powerful enough to efficiently handle SQL-like queries. Like, iirc `WHERE Id > 500` still requires trying all the Id values, you can't binary search on keys like that. And clause order matters a lot for perf. Doesn't Datalog use a different sort of evaluator that makes such queries more tractable?
- simplify 2y agoThere's no inherent reason you couldn't do that. That's another similarity to SQL: the underlying features of the language will depend on which runtime you're using. SQL: Postgres, SQLite, MySql, etc. all have different features. Prolog: SWI-Prolog, GNU Prolog, Scryer Prolog, etc. same thing. It's true that Datalog is better for pure data querying. But there's no theoretical reason it couldn't be implemented in Prolog as well.