mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	feat: add partial index on client_applications annouced FALSE (#6166)
We have customers with tens or hundreds of thousands of applications, and we have a scheduler running that sets application fields to `announced` as true. However, every time it runs, it queries the entire table, which is slow and causes database connection acquisition issues. To make it faster, we added a partial index to the table.
This commit is contained in:
		
							parent
							
								
									c43d7c0653
								
							
						
					
					
						commit
						bc7d4b8edb
					
				@ -0,0 +1,17 @@
 | 
			
		||||
'use strict';
 | 
			
		||||
 | 
			
		||||
exports.up = function(db, cb) {
 | 
			
		||||
    db.runSql(
 | 
			
		||||
        `
 | 
			
		||||
            CREATE INDEX IF NOT EXISTS idx_client_applications_announced_false ON client_applications (announced)
 | 
			
		||||
                WHERE announced = FALSE;
 | 
			
		||||
        `,
 | 
			
		||||
        cb,
 | 
			
		||||
    );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.down = function(db, cb) {
 | 
			
		||||
    db.runSql(`
 | 
			
		||||
        DROP INDEX IF EXISTS idx_client_applications_announced_false;
 | 
			
		||||
    `, cb);
 | 
			
		||||
};
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user