4

In Stack Exchange Data Explorer, I noticed that after a query is executed, it is stored in the cache (I think). How do I disable this feature?

For example, when I run this query, it should generate a random decimal number every time it runs. However, after the first execution, it is returning the same output. How do I fix that?

Query:

SELECT RAND(); 

Output:

1st Output: 0.43478413831866264
2nd Output: 0.43478413831866264
3rd Output: 0.43478413831866264

Data Explorer Links:
Revision 01: https://data.stackexchange.com/stackoverflow/revision/1017263/1256481
Revision 02: https://data.stackexchange.com/stackoverflow/revision/1017263/1256480
Revision 03: https://data.stackexchange.com/stackoverflow/revision/1017263/1256479

Same query on SQLFiddle.com: http://sqlfiddle.com/#!18/9eecb/40059/0

1st Output: 0.7295917643723033
2nd Output: 0.42465768701227824
3rd Output: 0.8141123124641404

Update:
Please note that this SQL code is just an example.

1

3 Answers 3

6

Expanding on Laurel's idea and my own comment: suppose you have a query with a parameter named seed. Then you can hook on running the query and give the seed a new value with this small JavaScript snippet:

$("#runQueryForm").submit(function(event) {
    $("input[name='seed']").attr("value", Math.floor(Math.random() * Math.pow(2, 31))); 
});

You can run the code in your browser console, and I've made it part of my userscript that restores the old functionality of automatically filling the user ID, which has now been rebranded as SEDE Parameter Autofiller.

enter image description here

1
  • 2
    It's either executing that in the console, or installing a userscript. There's no way to do this in a more user-friendly way.
    – Glorfindel Mod
    Commented Mar 27, 2019 at 15:51
5

I found a solution:

Note that if the query requires you to fill in parameters before running, you'll only get the cached results if you enter the same values as were specified for the cached run...

A: Why do Data Explorer queries sometimes load and run, and other times just load?

You get random results with select rand(), ##seed## then inputting a different seed each time.

0
4

Looks like SEDE cache maps the raw SQL to the results.

So to get a fresh result, just change the SQL. (Comments don't count, sadly)

Easiest way in this case is adding 0:

SELECT RAND() + 0

Then you can also:

SELECT RAND() + 0.0

And:

SELECT RAND() + 0.00

etc...

1
  • 1
    @DxTx " data explorer can be used as a demo website to show outputs" - no, please don't. It's not what it exists for, and if it will be abused too much SE will shut it down. So please, just don't do it. Commented Mar 28, 2019 at 9:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .