@@ -3136,3 +3136,302 @@ EXPLAIN SELECT COUNT(*) FROM t1;
31363136(6 rows)
31373137
31383138DROP TABLE t1;
3139+ /* =========================
3140+ * ===test cache eviction===
3141+ * =========================
3142+ */
3143+ CREATE TABLE integer_table (
3144+ id SERIAL PRIMARY KEY,
3145+ col1 INTEGER,
3146+ col2 INTEGER,
3147+ col3 INTEGER,
3148+ col4 INTEGER,
3149+ col5 INTEGER,
3150+ col6 INTEGER,
3151+ col7 INTEGER,
3152+ col8 INTEGER,
3153+ col9 INTEGER,
3154+ col10 INTEGER,
3155+ col11 INTEGER,
3156+ col12 INTEGER,
3157+ col13 INTEGER,
3158+ col14 INTEGER,
3159+ col15 INTEGER,
3160+ col16 INTEGER,
3161+ col17 INTEGER,
3162+ col18 INTEGER,
3163+ col19 INTEGER,
3164+ col20 INTEGER,
3165+ col21 INTEGER,
3166+ col22 INTEGER,
3167+ col23 INTEGER,
3168+ col24 INTEGER,
3169+ col25 INTEGER,
3170+ col26 INTEGER,
3171+ col27 INTEGER,
3172+ col28 INTEGER,
3173+ col29 INTEGER,
3174+ col30 INTEGER,
3175+ col31 INTEGER,
3176+ col32 INTEGER,
3177+ col33 INTEGER,
3178+ col34 INTEGER,
3179+ col35 INTEGER,
3180+ col36 INTEGER,
3181+ col37 INTEGER,
3182+ col38 INTEGER,
3183+ col39 INTEGER,
3184+ col40 INTEGER,
3185+ col41 INTEGER,
3186+ col42 INTEGER,
3187+ col43 INTEGER,
3188+ col44 INTEGER,
3189+ col45 INTEGER,
3190+ col46 INTEGER,
3191+ col47 INTEGER,
3192+ col48 INTEGER,
3193+ col49 INTEGER,
3194+ col50 INTEGER,
3195+ col51 INTEGER,
3196+ col52 INTEGER,
3197+ col53 INTEGER,
3198+ col54 INTEGER,
3199+ col55 INTEGER,
3200+ col56 INTEGER,
3201+ col57 INTEGER,
3202+ col58 INTEGER,
3203+ col59 INTEGER,
3204+ col60 INTEGER,
3205+ col61 INTEGER,
3206+ col62 INTEGER,
3207+ col63 INTEGER,
3208+ col64 INTEGER,
3209+ col65 INTEGER,
3210+ col66 INTEGER,
3211+ col67 INTEGER,
3212+ col68 INTEGER,
3213+ col69 INTEGER,
3214+ col70 INTEGER,
3215+ col71 INTEGER,
3216+ col72 INTEGER,
3217+ col73 INTEGER,
3218+ col74 INTEGER,
3219+ col75 INTEGER,
3220+ col76 INTEGER,
3221+ col77 INTEGER,
3222+ col78 INTEGER,
3223+ col79 INTEGER,
3224+ col80 INTEGER,
3225+ col81 INTEGER,
3226+ col82 INTEGER,
3227+ col83 INTEGER,
3228+ col84 INTEGER,
3229+ col85 INTEGER,
3230+ col86 INTEGER,
3231+ col87 INTEGER,
3232+ col88 INTEGER,
3233+ col89 INTEGER,
3234+ col90 INTEGER,
3235+ col91 INTEGER,
3236+ col92 INTEGER,
3237+ col93 INTEGER,
3238+ col94 INTEGER,
3239+ col95 INTEGER,
3240+ col96 INTEGER,
3241+ col97 INTEGER,
3242+ col98 INTEGER,
3243+ col99 INTEGER,
3244+ col100 INTEGER
3245+ );
3246+ INSERT INTO integer_table (
3247+ col1, col2, col3, col4, col5, col6, col7, col8, col9, col10,
3248+ col11, col12, col13, col14, col15, col16, col17, col18, col19, col20,
3249+ col21, col22, col23, col24, col25, col26, col27, col28, col29, col30,
3250+ col31, col32, col33, col34, col35, col36, col37, col38, col39, col40,
3251+ col41, col42, col43, col44, col45, col46, col47, col48, col49, col50,
3252+ col51, col52, col53, col54, col55, col56, col57, col58, col59, col60,
3253+ col61, col62, col63, col64, col65, col66, col67, col68, col69, col70,
3254+ col71, col72, col73, col74, col75, col76, col77, col78, col79, col80,
3255+ col81, col82, col83, col84, col85, col86, col87, col88, col89, col90,
3256+ col91, col92, col93, col94, col95, col96, col97, col98, col99, col100
3257+ )
3258+ SELECT
3259+ trunc(random() * 1000)::INTEGER AS col1,
3260+ trunc(random() * 1000)::INTEGER AS col2,
3261+ trunc(random() * 1000)::INTEGER AS col3,
3262+ trunc(random() * 1000)::INTEGER AS col4,
3263+ trunc(random() * 1000)::INTEGER AS col5,
3264+ trunc(random() * 1000)::INTEGER AS col6,
3265+ trunc(random() * 1000)::INTEGER AS col7,
3266+ trunc(random() * 1000)::INTEGER AS col8,
3267+ trunc(random() * 1000)::INTEGER AS col9,
3268+ trunc(random() * 1000)::INTEGER AS col10,
3269+ trunc(random() * 1000)::INTEGER AS col11,
3270+ trunc(random() * 1000)::INTEGER AS col12,
3271+ trunc(random() * 1000)::INTEGER AS col13,
3272+ trunc(random() * 1000)::INTEGER AS col14,
3273+ trunc(random() * 1000)::INTEGER AS col15,
3274+ trunc(random() * 1000)::INTEGER AS col16,
3275+ trunc(random() * 1000)::INTEGER AS col17,
3276+ trunc(random() * 1000)::INTEGER AS col18,
3277+ trunc(random() * 1000)::INTEGER AS col19,
3278+ trunc(random() * 1000)::INTEGER AS col20,
3279+ trunc(random() * 1000)::INTEGER AS col21,
3280+ trunc(random() * 1000)::INTEGER AS col22,
3281+ trunc(random() * 1000)::INTEGER AS col23,
3282+ trunc(random() * 1000)::INTEGER AS col24,
3283+ trunc(random() * 1000)::INTEGER AS col25,
3284+ trunc(random() * 1000)::INTEGER AS col26,
3285+ trunc(random() * 1000)::INTEGER AS col27,
3286+ trunc(random() * 1000)::INTEGER AS col28,
3287+ trunc(random() * 1000)::INTEGER AS col29,
3288+ trunc(random() * 1000)::INTEGER AS col30,
3289+ trunc(random() * 1000)::INTEGER AS col31,
3290+ trunc(random() * 1000)::INTEGER AS col32,
3291+ trunc(random() * 1000)::INTEGER AS col33,
3292+ trunc(random() * 1000)::INTEGER AS col34,
3293+ trunc(random() * 1000)::INTEGER AS col35,
3294+ trunc(random() * 1000)::INTEGER AS col36,
3295+ trunc(random() * 1000)::INTEGER AS col37,
3296+ trunc(random() * 1000)::INTEGER AS col38,
3297+ trunc(random() * 1000)::INTEGER AS col39,
3298+ trunc(random() * 1000)::INTEGER AS col40,
3299+ trunc(random() * 1000)::INTEGER AS col41,
3300+ trunc(random() * 1000)::INTEGER AS col42,
3301+ trunc(random() * 1000)::INTEGER AS col43,
3302+ trunc(random() * 1000)::INTEGER AS col44,
3303+ trunc(random() * 1000)::INTEGER AS col45,
3304+ trunc(random() * 1000)::INTEGER AS col46,
3305+ trunc(random() * 1000)::INTEGER AS col47,
3306+ trunc(random() * 1000)::INTEGER AS col48,
3307+ trunc(random() * 1000)::INTEGER AS col49,
3308+ trunc(random() * 1000)::INTEGER AS col50,
3309+ trunc(random() * 1000)::INTEGER AS col51,
3310+ trunc(random() * 1000)::INTEGER AS col52,
3311+ trunc(random() * 1000)::INTEGER AS col53,
3312+ trunc(random() * 1000)::INTEGER AS col54,
3313+ trunc(random() * 1000)::INTEGER AS col55,
3314+ trunc(random() * 1000)::INTEGER AS col56,
3315+ trunc(random() * 1000)::INTEGER AS col57,
3316+ trunc(random() * 1000)::INTEGER AS col58,
3317+ trunc(random() * 1000)::INTEGER AS col59,
3318+ trunc(random() * 1000)::INTEGER AS col60,
3319+ trunc(random() * 1000)::INTEGER AS col61,
3320+ trunc(random() * 1000)::INTEGER AS col62,
3321+ trunc(random() * 1000)::INTEGER AS col63,
3322+ trunc(random() * 1000)::INTEGER AS col64,
3323+ trunc(random() * 1000)::INTEGER AS col65,
3324+ trunc(random() * 1000)::INTEGER AS col66,
3325+ trunc(random() * 1000)::INTEGER AS col67,
3326+ trunc(random() * 1000)::INTEGER AS col68,
3327+ trunc(random() * 1000)::INTEGER AS col69,
3328+ trunc(random() * 1000)::INTEGER AS col70,
3329+ trunc(random() * 1000)::INTEGER AS col71,
3330+ trunc(random() * 1000)::INTEGER AS col72,
3331+ trunc(random() * 1000)::INTEGER AS col73,
3332+ trunc(random() * 1000)::INTEGER AS col74,
3333+ trunc(random() * 1000)::INTEGER AS col75,
3334+ trunc(random() * 1000)::INTEGER AS col76,
3335+ trunc(random() * 1000)::INTEGER AS col77,
3336+ trunc(random() * 1000)::INTEGER AS col78,
3337+ trunc(random() * 1000)::INTEGER AS col79,
3338+ trunc(random() * 1000)::INTEGER AS col80,
3339+ trunc(random() * 1000)::INTEGER AS col81,
3340+ trunc(random() * 1000)::INTEGER AS col82,
3341+ trunc(random() * 1000)::INTEGER AS col83,
3342+ trunc(random() * 1000)::INTEGER AS col84,
3343+ trunc(random() * 1000)::INTEGER AS col85,
3344+ trunc(random() * 1000)::INTEGER AS col86,
3345+ trunc(random() * 1000)::INTEGER AS col87,
3346+ trunc(random() * 1000)::INTEGER AS col88,
3347+ trunc(random() * 1000)::INTEGER AS col89,
3348+ trunc(random() * 1000)::INTEGER AS col90,
3349+ trunc(random() * 1000)::INTEGER AS col91,
3350+ trunc(random() * 1000)::INTEGER AS col92,
3351+ trunc(random() * 1000)::INTEGER AS col93,
3352+ trunc(random() * 1000)::INTEGER AS col94,
3353+ trunc(random() * 1000)::INTEGER AS col95,
3354+ trunc(random() * 1000)::INTEGER AS col96,
3355+ trunc(random() * 1000)::INTEGER AS col97,
3356+ trunc(random() * 1000)::INTEGER AS col98,
3357+ trunc(random() * 1000)::INTEGER AS col99,
3358+ trunc(random() * 1000)::INTEGER AS col100
3359+ FROM generate_series(1, 60000);
3360+ -- size should be greater 25Mb
3361+ SELECT pg_size_pretty(pg_table_size('integer_table')) AS table_size;
3362+ table_size
3363+ ------------
3364+ 26 MB
3365+ (1 row)
3366+
3367+ -- prepare conversion to columnar (will be error, if not to drop)
3368+ DROP SEQUENCE integer_table_id_seq CASCADE;
3369+ NOTICE: drop cascades to default value for column id of table integer_table
3370+ --with 'copy_integer_table' we will compare integer_table after conversions
3371+ CREATE TABLE copy_integer_table AS
3372+ SELECT *
3373+ FROM integer_table;
3374+ --convert 'integer_table' to columnar
3375+ SELECT columnar.alter_table_set_access_method('integer_table','columnar');
3376+ alter_table_set_access_method
3377+ -------------------------------
3378+ t
3379+ (1 row)
3380+
3381+ -- check table size
3382+ SELECT pg_size_pretty(pg_table_size('integer_table')) AS table_size;
3383+ table_size
3384+ ------------
3385+ 11 MB
3386+ (1 row)
3387+
3388+ -- set caching GUCs
3389+ -- should be 200. If no, correct below 'SET columnar.column_cache_size = 200'
3390+ SHOW columnar.column_cache_size;
3391+ columnar.column_cache_size
3392+ ----------------------------
3393+ 200MB
3394+ (1 row)
3395+
3396+ SET columnar.column_cache_size = 20;
3397+ SET columnar.enable_column_cache = 't';
3398+ SELECT columnar.alter_table_set_access_method('integer_table', 'heap');
3399+ alter_table_set_access_method
3400+ -------------------------------
3401+ t
3402+ (1 row)
3403+
3404+ SELECT pg_size_pretty(pg_table_size('integer_table')) AS table_size;
3405+ table_size
3406+ ------------
3407+ 26 MB
3408+ (1 row)
3409+
3410+ -- Check table contents are the same after conversion heap->columnar->heap
3411+ SELECT * FROM integer_table
3412+ EXCEPT
3413+ SELECT * FROM copy_integer_table;
3414+ id | col1 | col2 | col3 | col4 | col5 | col6 | col7 | col8 | col9 | col10 | col11 | col12 | col13 | col14 | col15 | col16 | col17 | col18 | col19 | col20 | col21 | col22 | col23 | col24 | col25 | col26 | col27 | col28 | col29 | col30 | col31 | col32 | col33 | col34 | col35 | col36 | col37 | col38 | col39 | col40 | col41 | col42 | col43 | col44 | col45 | col46 | col47 | col48 | col49 | col50 | col51 | col52 | col53 | col54 | col55 | col56 | col57 | col58 | col59 | col60 | col61 | col62 | col63 | col64 | col65 | col66 | col67 | col68 | col69 | col70 | col71 | col72 | col73 | col74 | col75 | col76 | col77 | col78 | col79 | col80 | col81 | col82 | col83 | col84 | col85 | col86 | col87 | col88 | col89 | col90 | col91 | col92 | col93 | col94 | col95 | col96 | col97 | col98 | col99 | col100
3415+ ----+------+------+------+------+------+------+------+------+------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+--------
3416+ (0 rows)
3417+
3418+ SELECT * FROM copy_integer_table
3419+ EXCEPT
3420+ SELECT * FROM integer_table;
3421+ id | col1 | col2 | col3 | col4 | col5 | col6 | col7 | col8 | col9 | col10 | col11 | col12 | col13 | col14 | col15 | col16 | col17 | col18 | col19 | col20 | col21 | col22 | col23 | col24 | col25 | col26 | col27 | col28 | col29 | col30 | col31 | col32 | col33 | col34 | col35 | col36 | col37 | col38 | col39 | col40 | col41 | col42 | col43 | col44 | col45 | col46 | col47 | col48 | col49 | col50 | col51 | col52 | col53 | col54 | col55 | col56 | col57 | col58 | col59 | col60 | col61 | col62 | col63 | col64 | col65 | col66 | col67 | col68 | col69 | col70 | col71 | col72 | col73 | col74 | col75 | col76 | col77 | col78 | col79 | col80 | col81 | col82 | col83 | col84 | col85 | col86 | col87 | col88 | col89 | col90 | col91 | col92 | col93 | col94 | col95 | col96 | col97 | col98 | col99 | col100
3422+ ----+------+------+------+------+------+------+------+------+------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+--------
3423+ (0 rows)
3424+
3425+ SELECT COUNT(*) FROM integer_table
3426+ EXCEPT
3427+ SELECT COUNT(*) FROM copy_integer_table;
3428+ count
3429+ -------
3430+ (0 rows)
3431+
3432+ -- cleaning
3433+ DROP TABLE integer_table;
3434+ DROP TABLE copy_integer_table;
3435+ -- restore caching GUCs
3436+ SET columnar.enable_column_cache = 'f';
3437+ SET columnar.column_cache_size = 200;
0 commit comments