question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using variables destroys performance

See original GitHub issue

Query without variables:

{
  user_news(where: {user_id: {_eq: 1}, status: {_eq: 0}}, limit: 10, order_by: {id: desc}) {
    id
  }
}

Throughput: 3800 req/s

Query with variables:

query($user:Int, $status: Int){
  user_news(where: {user_id: {_eq: $user}, status: {_eq: $status}}, limit: 10, order_by: {id: desc}) {
    id
  }
}

Variables:

{
  "user":1,
  "status":0
}

Throughput: 980 req/s

In more complex example where I first noticed this performance drop it went from ~1500req/s to ~250req/s.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
wooquecommented, Jun 3, 2019

Yep, non nullable variables brought it to 90+% of non variable query performance. This should really be in documentation because it will byte a lot of people, I didn’t even know that variables could be nullable, let alone that there is big difference in performance.

The trick with with GHCRTS also improved performance for quite a bit, I’m surprised it’s not default

0reactions
wooquecommented, Jun 4, 2019

Thanks. I would leave this open as reminder

Read more comments on GitHub >

github_iconTop Results From Across the Web

Java Destruction of Variables - Stack Overflow
Java uses a garbage collector, so unused objects are disposed of automatically. In your example you use only local variables ...
Read more >
Efficiency when declaring variables - Unity Answers
Hi. I've researched for a while about the most efficient way to declare variables, and I haven't found a definitive answer.
Read more >
Global vs Local variable performance - Arduino Forum
I've often read that global variables have a slight performance edge ... and destroyed faster than a global variable is assigned a value?...
Read more >
Thread environment variables - IBM
If the program contains a large number of active condition variables and frequently creates and destroys condition variables, this can create higher overhead ......
Read more >
CUDA C++ Programming Guide - NVIDIA Documentation Center
Performance Guidelines gives some guidance on how to achieve maximum performance. ... When a host thread calls cudaDeviceReset() , this destroys the primary ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found