orientechnologies / orientjs

The official fast, lightweight node.js client for OrientDB
http://orientdb.com
Other
326 stars 68 forks source link

slow performance in order by #407

Closed amirrezamahyari closed 5 years ago

amirrezamahyari commented 5 years ago

Hi i have a class with 2m records when i run query in orientdb studio , query runs in 0.044 sec

SELECT * FROM Job WHERE status='waiting' AND queue=#27:0 AND queue.status='resume' ORDER BY timestamp asc, priority asc LIMIT 3

but same query in orientjs takes about 20 sec

        db.select()
        .from("Job")
        .where({ status: "waiting", queue: queueRID })
        .order(["timestamp ASC", " priority ASC"])
        .limit(limit)
        .all();

when i remove .order(["timestamp ASC", " priority ASC"]) line its better and runs in 3sec. all fields i used in query have index...

Screen Shot 2019-11-15 at 7 55 46 PM

orientjs: 3.0.8 orientdb:3.0.24

saeedtabrizi commented 5 years ago

Hi @amirrezamahyari As i see the two different query appears here . First of all you must be implement same query in orientjs to compare results . I guess this is not related to orientjs , but you must improve your query plan for better result .

amirrezamahyari commented 5 years ago

hi @saeedtabrizi i also testdb.query('SELECT * FROM Job WHERE status="waiting" AND queue=#27:0 AND queue.status="resume" ORDER BY timestamp asc, priority asc LIMIT 3') but same result its take time about 20 sec ... in orientdb studio it take 0.044 sec

wolf4ood commented 5 years ago

Hi @amirrezamahyari

which API are you using of OrientJS.

This

http://orientdb.com/docs/3.0.x/orientjs/OrientJS-Legacy.html

Or this

http://orientdb.com/docs/3.0.x/orientjs/OrientJS.html

Thanks

amirrezamahyari commented 5 years ago

Hi @wolf4ood i use legacy

wolf4ood commented 5 years ago

Hi @amirrezamahyari

that should explains the difference with Studio. Studio and OrientJS 3.0 with new API uses the new parser/executor in OrientDB 3.0.x while the legacy api for backward compatibility uses the old parser/executor.

Try the new OrientJS API, and let me know if it's the case.

Thanks

amirrezamahyari commented 5 years ago

@wolf4ood after move to new api everything is fine , thanks