6

Hi I am now building a website using aws NeptuneDB(Gremlin), NodeJs as Backend and Angular as Frontend. Now I am facing a problem, I want to do pagination on my website because without pagination I may load and display 5000 items one query. I know in MySQL, we can using like

select * from mydb limit 0, 20;

to do pagination.

Can I achieve similar in NeptuneDB(or GraphDB). I investigated for a while and I found this: How to perform pagination in Gremlin

Refer to the answer of this question, It seems we cannot avoid loading all query results into memory. Does it mean it doesn't make any difference with or without the pagination.

Or can I achieve pagination between Node and Angular(I am just guessing)?

So Any ideas to improve performance?

Kelvin Lawrence
  • 14,674
  • 2
  • 16
  • 38
Hongli Bu
  • 461
  • 12
  • 37

2 Answers2

0

It seems I can use like

g.V('vertice').out('some_relationship').order().by().range(0,3)

The order can be guarantee through order() But the problem is: In pagination, we need to get three parameters: currentPage, PageSize, TotalNumOfItems', currentPage and PageSize is pass from frontend, but how can we get the total number before retrieving items?

my way is just count before retrieve items:

g.V('vertice').out('some_relationship').count()
g.V('vertice').out('some_relationship').order().by().range(0,3)

Will this work?

Hongli Bu
  • 461
  • 12
  • 37
  • 1
    In terms of performance, calling .count() might be bad idea if out('some_relationship') , has large number of data. But if you need to display TotalNumOfItems , then this will work – ashoksl Jan 24 '20 at 06:26
0

It's been a while since this question was asked.

Since then a Result Cache feature has been added to Amazon Neptune that makes doing pagination with Gremlin queries a lot easier. The cache has various features including a Time To Live (TTL) option and ways to paginate over a result set. This helps both with single queries that are expensive and queries that have large amounts of results.

You can find the details here.

Kelvin Lawrence
  • 14,674
  • 2
  • 16
  • 38