cache and procedure
See original GitHub issueDear developers i am use mysql2 lib with PoolConnection on ExpressJS. When I make a two request (changing the parameters of the request), I get old (cached) data sometimes (reloading the page). Is it somehow connected with Lru cached, but it is impossible to disable it through the connection parameters or it bug?
in docunetation say: // If you execute same statement again, it will be picked from a LRU cache // which will save query preparation time and give better performance but i use Procedure and PoolQuery . Patching my CALL procedure added Math.Random but it had no effect
my source code
const mysql = require('mysql2');
const mysqlpool = mysql.createPool({
host: 'localhost',
user: 'root',
database: 'base_test',
waitForConnections: true,
connectionLimit: 10,
queueLimit: 0,
multipleStatements: false,
//caching: true
});
module.exports.getQuery = function (str,brand,resout) {
let rnd = Math.random();
let sqlProcedure = 'CALL alfaquery_v2(?,?);';
mysqlpool.query(
sqlProcedure,[str,rnd],
function(err, rows) {
if (err) {
console.log(err);
resout.send([]);
}
console.log(rows[0]);
resout.send(rows[0]);
});
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Procedure cache
Procedure cache. Adaptive Server maintains an MRU/LRU (most recently used/least recently used) chain of stored procedure query plans.
Read more >Understanding SQL Server query plan cache - SQLShack
Every query requires a query plan before it is actually executed. This query plan is stored in SQL Server query plan cache.
Read more >How to Cache Stored Procedure Results - Brent Ozar Unlimited
This outright-truncation technique is less efficient for refreshing the cache, but it minimizes the locking required by deletes. In a caching ...
Read more >Cache a Procedure - TechDocs - Broadcom Inc.
You can create, display, and delete cache entries by using the PCACHE and CPROC commands. A cached copy of a procedure is also...
Read more >Procedure Cache - SAP Help Portal
SAP ASE maintains an MRU/LRU (most recently used/least recently used) chain of stored procedure query plans. As users execute stored procedures, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I solved the issue. The culprit was the transactions! I think there is a bug with transactions. I replaced all of the transactions with regular queries and now everything is working fine.
I hit the same case today. Disabling transactions does the job, but it’s not an option for me.