mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	presence: Add realm/timestamp index to UserPresence.
It adds this index:
    "zerver_userpresence_realm_id_timestamp_25f410da_idx" btree (realm_id, "timestamp")
We expect this index to provide a major performance improvement when
fetching presence data for the whole realm from the database on
servers like zulipchat.com hosting several realms.
			
			
This commit is contained in:
		@@ -2327,9 +2327,12 @@ class UserPresence(models.Model):
 | 
			
		||||
    """
 | 
			
		||||
    class Meta:
 | 
			
		||||
        unique_together = ("user_profile", "client")
 | 
			
		||||
        index_together = [
 | 
			
		||||
            ("realm", "timestamp")
 | 
			
		||||
        ]
 | 
			
		||||
 | 
			
		||||
    user_profile = models.ForeignKey(UserProfile, on_delete=CASCADE)  # type: UserProfile
 | 
			
		||||
    realm = models.ForeignKey(Realm, null=True)  # type: Optional[Realm]
 | 
			
		||||
    realm = models.ForeignKey(Realm)  # type: Realm
 | 
			
		||||
    client = models.ForeignKey(Client, on_delete=CASCADE)  # type: Client
 | 
			
		||||
 | 
			
		||||
    # The time we heard this update from the client.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user