mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	These extended statistics allow the query planner to know that the prevalence of empty topics is very different in DMs, as opposed to channel messages. The `ALTER STATISTICS` adjusts the size of the "most common value" list -- it must be large enough to include the empty-topic channel messages to be fully effective. Having this list be over-large does not carry much risk, however. The `ANALYZE zerver_message` step may be quite slow.
		
			
				
	
	
		
			22 lines
		
	
	
		
			788 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
		
			788 B
		
	
	
	
		
			Python
		
	
	
	
	
	
from django.db import migrations
 | 
						|
 | 
						|
 | 
						|
class Migration(migrations.Migration):
 | 
						|
    atomic = False
 | 
						|
 | 
						|
    dependencies = [
 | 
						|
        ("zerver", "0694_remove_message_unconditional_topic_indexes"),
 | 
						|
    ]
 | 
						|
 | 
						|
    operations = [
 | 
						|
        migrations.RunSQL(
 | 
						|
            sql="CREATE STATISTICS IF NOT EXISTS zerver_message_subject_is_channel_message ON subject, is_channel_message FROM zerver_message",
 | 
						|
            reverse_sql="DROP STATISTICS IF EXISTS zerver_message_subject_is_channel_message",
 | 
						|
        ),
 | 
						|
        migrations.RunSQL(
 | 
						|
            sql="ALTER STATISTICS zerver_message_subject_is_channel_message SET STATISTICS 1500",
 | 
						|
            reverse_sql="ALTER STATISTICS zerver_message_subject_is_channel_message SET STATISTICS -1",
 | 
						|
        ),
 | 
						|
        migrations.RunSQL("ANALYZE zerver_message"),
 | 
						|
    ]
 |