News for hackers. Stuff that matters.
Re:The GitHub GraphQL API by WorldMaker on Wednesday September 14, 2016 @03:28PM (#12500427)
The implication in this article and elsewhere is that that the most expensive queries happened anyway, but as sequences and patterns of requests before. I imagine that what is lost in caching common requests is gained back by being able to pattern analyze the bespoke requests as a whole, prioritize and even quota them specifically by the type of bespoke requests, much more so than you could by just guessing the pattern of incoming REST URL hits.

Just as a relational database itself can sometimes generate better query plans from its query analyzer if you feed it what you are really after in one big, slow query that narrows to very specific rows rather than lots of small queries that return lots of rows quickly. Amortized against the database's time (CPU, memory) and bandwidth that slightly slower query is still sometimes a big win for overall performance.

(Given that most GraphQL services are typically backed by relational databases, it should probably not be a surprise the savings sometimes get passed right along.)

Re:The GitHub GraphQL API by postila on Wednesday September 14, 2016 @07:29PM (#12502109)
Yes but if in the past you could blame your internal developer for making slow SQL query, now these rich possibilities to perform really stressful queries to your DBMS are open to the public, right?

The main riddle to me is: in case of RDBMS in backend, how can we guess in advance which indexes are needed and how can we forbid/limit all "heavy" queries?

Re:The GitHub GraphQL API by the_duke on Wednesday September 14, 2016 @07:47PM (#12502226)
GraphQL has a notion of query complexity, that you can use to forbid certain queries.

Also, where appropriate, you can still gain a lot with caching.

Simple example: cache the query response containing all fields of a table, and extract the fields required for the response.

Re:The GitHub GraphQL API by postila on Wednesday September 14, 2016 @07:52PM (#12502265)
Many people smarter than me do think that caching [SQL] queries proved to be really bad idea (regardless of DBMS). Why caching API queries would be better?

Even if I would use query caching, I cannot imagine how it would help me to deal with really long queries (say, lacking proper indexes). Caching doesn't help when your query runs for 30 seconds – nobody will wait (and produce cache for others) so long.