Is dgraph fit for time series and finding equal value in array

mutation

(jihantoro) #1

is DGraph database fit for this task :

  1. select by unix/epoch time, lower/upper (> or <) than given time (timeseries)
  2. database that support array, and find word/sentence inside the array

query example :

select * from tweet where created_at > start_at and created_at < end_at and keyword in arraycolumn

(Michel Conrado) #2
{
  q(func: has(tweet))@filter(gt(created_at, "2018") 
    AND lt(created_at, "2019") 
    AND eq(arraycolumn, "keyword")){
    expand(_all_)
  }
}

OR

{
  q(func: eq(arraycolumn, "keyword") )@filter(gt(created_at, "2018") 
    AND lt(created_at, "2019")  {
    expand(_all_)
  }
}

Where this “start_at” come from? and what is this “keyword” exactly?

yep

yep


(Dmitry Russ) #3

For information: This query could be slow without BTree index if there are many tweets all over the time and only time span makes result span smaller.


(yyyguy) #4

Hello,

So is this question answered? It is not clear to me if DGraph could/should be used for time series purposes. Is there a good definitive answer? I am looking to potentially use DGraph for a small dimensional database project, but I am uncertain if it will perform well over time.

Thoughts?


(Michel Conrado) #5

Yes, it is.

for those cases, you have to use

Inequality

https://docs.dgraph.io/query-language/#inequality

AND, OR and NOT

https://docs.dgraph.io/query-language/#and-or-and-not

Maybe in some cases, you could use Value Variables to catch some date from a specific node. And inject in a second block as param.

Value Variables

https://docs.dgraph.io/query-language/#value-variables

You could also use “Math on value variables” and/or “Aggregation”.

Aggregation

https://docs.dgraph.io/query-language/#aggregation

Math on value variables

https://docs.dgraph.io/query-language/#math-on-value-variables


(yyyguy) #6

Thanks, @MichelDiz.

I appreciate the references as well.