PostgreSQL/Postgresql 성능 및 분석 (2) 썸네일형 리스트형 count_distinct improvements count_distinct improvementsAlmost a year ago, I wrote a custom experimental aggregate replacing COUNT(DISTINCT). The problem with the native COUNT(DISTINCT) is that it forces a sort on the input relation, and when the amount of data is significant (say, tens of millions rows), that may be a significant performance drag. And sometimes we really need to do COUNT(DISTINCT).Extensibility is one of t.. Making sorts happen in memory instead of on disk Making sorts happen in memory instead of on diskIf you have disk-based sorts occurring frequently, you can find the size of the largest of the frequent queries and then set this as the standard threshold for sorts. The parameter for this in/var/lib/pgsql/data/postgresql.conf is 'work_mem'. For example, if you had frequent disk-spaced sorts using up to 64MB, you would set the following in /var/li..