Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » sci.math.* » sci.math.independent

Topic: PROLOG ENGINES ARE REALLLLLLY SLOW! ((SQL-UNIFY))
Replies: 5   Last Post: Nov 20, 2012 4:40 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Graham Cooper

Posts: 4,247
Registered: 5/20/10
Re: PROLOG ENGINES ARE REALLLLLLY SLOW! ((SQL-UNIFY))
Posted: Nov 20, 2012 3:16 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On Nov 21, 1:46 am, Jan Burse <janbu...@fastmail.fm> wrote:
> Graham Cooper schrieb:
>  > A lot of variable renaming conventions, trial and error,
>  > backtracking... very tricky and particular code covering
>  > dozens of potential matching scenerios!
>
> Already efficiently solved to some extend in the 70's. Have
> a read about the early childhood of Prolog systems:
>
> La naissance de Prolog
> Juillet 1992, A. Colmerauer, P. Rousselhttp://prolog.developpez.com/tutoriels/alain-colmerauer/histoire-prol...
>

> > Slight drawback is program order is lost using the fastest match
> > method, but PROLOG is overused as a simple FETCH cycle for 3GL style
> > coding.

>
> Add an additional sorting column, and you can preserve the input order.
> Any Prolog system implementing multi-argument indexing has also to
> solve this problem, in that the index lookup bust deliver a clause set
> which is actually a clause list ordered by the input order.
>
> Bye


SQL-UNIFY
SELECT * FROM TTAILS, TPRO
WHERE TTAILS.REF = TPRO.REF
AND TTAILS.FIELD = TPRO.FIELD
GROUP BY COUNT(TPRO.ID)
ORDER BY COUNT(TPRO.ID) DESC


Right, actually I think the GROUP BY would be inefficient and only do
Breadth First, i.e. calculate the whole table then sort, although it
would find the best rule (most terms matched 1st).

SQL-UNIFY
SELECT * FROM TTAILS, TPRO
WHERE TTAILS.REF = TPRO.REF
AND TTAILS.FIELD = TPRO.FIELD
ORDER BY TPRO.ID

This will preserve program order and be LAZY Evaluation so PHP can
test the 1st match 1st then fetch more records from this result if
needed.

Herc



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.