摘要:
greenplum最终的方法是: delete from test where (gp_segment_id, ctid) not in (select gp_segment_id, min(ctid) from test group by x, gp_segment_id); postgresql 阅读全文
posted @ 2019-01-03 19:43
月图灵
阅读(2901)
评论(0)
推荐(0)
摘要:
postgresql的排序。 https://www.cnblogs.com/flying-tiger/p/8120046.html 1.是根据排序数据量的大小来判断,如果数据量少到能够整体放到内存的话,就直接快速排序, 2.数据量较大内存放不下,但是所需要返回的元组内存可以装下或者TOP N的性能 阅读全文
posted @ 2019-01-03 19:27
月图灵
阅读(1980)
评论(0)
推荐(0)
摘要:
https://blog.codinghorror.com/the-infinite-space-between-words/ 磁盘耗时时间 阅读全文
posted @ 2019-01-03 19:08
月图灵
阅读(239)
评论(0)
推荐(0)
摘要:
pg_log,数据库日志表postgresqllog CREATE TABLE postgres_log ( log_time timestamp(3) with time zone, 日志生成时间 user_name text, 登陆用户名 database_name text, 数据库名 pro 阅读全文
posted @ 2019-01-03 19:07
月图灵
阅读(1365)
评论(0)
推荐(0)
摘要:
查看各个数据库表大小(不包含索引),以及表数据量 mysql: select table_name,concat(round((DATA_LENGTH/1024/1024),2),'M')as size,table_rows from information_schema.tables order 阅读全文
posted @ 2019-01-03 19:05
月图灵
阅读(4427)
评论(0)
推荐(0)
摘要:
清空os缓存,shared_buffers 1.停止数据库 pg_ctl -m fast -D /pgdata stop 2.清空高速缓存前尝试将数据刷新至磁盘 sync 3.清空缓存 echo 3 > /proc/sys/vm/drop_caches 4.启动数据库 pg_ctl -D /pgda 阅读全文
posted @ 2019-01-03 19:03
月图灵
阅读(1436)
评论(0)
推荐(0)
摘要:
在postgresql9.5的时候做过一个测试就是sum()的效率最终的测试结果是sum(int)>sum(numeric)>sum(bigint)当时比较诧异为啥sum(bigint)效率比sum(numeric)还低。sum(numeric)的效率比sum(bigint)快了10%。 在pg10 阅读全文
posted @ 2019-01-03 18:55
月图灵
阅读(5621)
评论(0)
推荐(0)
摘要:
drop table tablesize create table tablesize( phone int) create table tablesize( phone text) create table tablesize( phone char(30)) create table table 阅读全文
posted @ 2019-01-03 18:50
月图灵
阅读(1204)
评论(0)
推荐(0)
摘要:
mongodb pg mysql jsonb对比 http://erthalion.info/2017/12/21/advanced-json-benchmarks/ 使用禁用jsonb列的压缩 ALTER TABLE table_name ALTER COLUMN column SET STORA 阅读全文
posted @ 2019-01-03 18:49
月图灵
阅读(1618)
评论(0)
推荐(0)
摘要:
redis 和postgresql区别以及其优缺点 一刹那者为一念,二十念为一瞬,二十瞬为一弹指,二十弹指为一罗预,二十罗预为一须臾,一日一夜有三十须臾。 那么,经过周密的计算,一瞬间为0.36 秒,一刹那有 0.018 秒.一弹指长达 7.2 秒。 redis和postgresql区别: pg是一 阅读全文
posted @ 2019-01-03 18:02
月图灵
阅读(7147)
评论(0)
推荐(1)
摘要:
死锁问题:1.长事务,事务中包含了文书的上传下载,导致其他表的锁等待,最终导致死锁。 2.并发更新,如果更新慢的话,很可能导致,锁等待。需要加for update或者ad lock 3.数据库中查询pg_stat_activity中有idle in transaction说明有长事务,很有可能是事务 阅读全文
posted @ 2019-01-03 17:38
月图灵
阅读(385)
评论(0)
推荐(0)
摘要:
pg_prewarm数据预加载。 http://francs3.blog.163.com/blog/static/405767272014419114519709/ https://www.kancloud.cn/taobaomysql/monthly/67170 可能有人比较疑惑:执行1次sele 阅读全文
posted @ 2019-01-03 17:32
月图灵
阅读(1189)
评论(0)
推荐(1)
摘要:
crontab -e 在最后添加: # backup database at 22:00 every day 0 22 * * * pg /home/eric/bin/backup-db.sh 这样每天22:00时就会自动执行 pg_dump 以备份testdb数据库。 定时任务备份脚本: sele 阅读全文
posted @ 2019-01-03 17:31
月图灵
阅读(3713)
评论(0)
推荐(0)
摘要:
递增uuid的优点: https://blog.2ndquadrant.com/on-the-impact-of-full-page-writes/ 减小wal生成 阅读全文
posted @ 2019-01-03 17:29
月图灵
阅读(565)
评论(0)
推荐(0)
摘要:
既有ssd又有hdd是将数据存储到ssd还是将索引存储到ssd的效率更高呢? 一种说法是索引是随机扫描,将索引放入ssd效率会增高, 一种说法是将数据放入ssd效率更高 最好的情况是将数据和索引都放到ssd,效率可以提高5-6倍。 为什么在ssd上面放置索引效率没有ssd存表效率高呢? 1.索引通常 阅读全文
posted @ 2019-01-03 17:26
月图灵
阅读(738)
评论(0)
推荐(0)
摘要:
tps TPS就是每秒事务数,但是事务是基于虚拟用户数的,假如1个虚拟用户在1秒内完成1笔事务,那么TPS明显就是1;如果 某笔业务响应时间是1ms,那么1个用户在1秒内能完成1000笔事务,TPS就是1000了;如果某笔业务响应时间是1s,那么1个用户在1秒内只能完 成1笔事务,要想达到1000T 阅读全文
posted @ 2019-01-03 17:23
月图灵
阅读(1486)
评论(0)
推荐(0)
摘要:
PostgreSQL 的 distinct on 的理解 对于 select distinct on , 可以利用下面的例子来理解: create table a6(id integer, name varchar(10)); insert into a6 values(1, ' 001'); in 阅读全文
posted @ 2019-01-03 17:22
月图灵
阅读(3471)
评论(0)
推荐(1)
摘要:
pgbench测试: pg9.6.2的pgbench报错: [pg@localhost ~]$ pgbench -S -c 8 -t 60 pgbenchdb Segmentation fault (core dumped): https://www.postgresql-archive.org/B 阅读全文
posted @ 2019-01-03 17:18
月图灵
阅读(906)
评论(0)
推荐(0)
摘要:
shared_buffers大小调整: http://www.rummandba.com/2011/02/sizing-sharedbuffer-of-postgresql.html SELECT usagecount,count(*),isdirty, round((count(*)/ max(t 阅读全文
posted @ 2019-01-03 17:16
月图灵
阅读(5919)
评论(2)
推荐(1)
摘要:
脏页和缓存失效 https://www.cnblogs.com/flying-tiger/p/7885478.html Dirty pages and cache invalidation 我们一直在说的是查询语句(SELECT),那么对于DML语句情况又有什么不一样呢? 很简单,他们将数据也写回到 阅读全文
posted @ 2019-01-03 17:15
月图灵
阅读(1270)
评论(0)
推荐(0)
摘要:
共享缓冲区 在内存中读取或写入数据总是比在任何其他介质上更快。数据库服务器还需要用于快速访问数据的内存,无论是READ还是WRITE访问。在PostgreSQL中,这被称为“共享缓冲区”,由参数shared_buffers控制。共享缓冲区所需的RAM总是在其生命周期内为PostgreSQL实例锁定。 阅读全文
posted @ 2019-01-03 17:14
月图灵
阅读(1288)
评论(0)
推荐(0)
摘要:
pg_stat_statements跳过的坑 原本以为只是一个简单的插件扩展安装,三下五除二就能搞定,结果搞了很久也没找到问题所在。首先pg_stat_statements已经安装成功,且已经能够使用create extension pg_stat_statements创建扩展成功,但是查询pg_s 阅读全文
posted @ 2019-01-03 17:12
月图灵
阅读(2296)
评论(0)
推荐(0)
摘要:
PostgreSQL 服务器发出的所有消息都赋予了五个字符 的错误代码, 这些代码遵循 SQL 的 "SQLSTATE" 代码的习惯。需要知道发生了什么错误条件的应用通常应该测试错误代码, 而不是查看文本错误信息。这些错误 代码轻易不会随着 PostgreSQL 的版本更新而修改, 并且一般也不会随 阅读全文
posted @ 2019-01-03 17:08
月图灵
阅读(4104)
评论(0)
推荐(0)
摘要:
postgresql 模糊匹配 目前建议使用like,~~,不建议使用正则表达式, 目前有性能问题 https://yq.aliyun.com/articles/405097 正则表达式效率比较低下: 操作符 ~~ 等效于 LIKE, 而 ~~* 对应 ILIKE。 还有 !~~ 和 !~~* 操作 阅读全文
posted @ 2019-01-03 17:04
月图灵
阅读(1554)
评论(0)
推荐(0)

浙公网安备 33010602011771号