Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Postgresql 从选择插入未命中某些行-Postgres_Postgresql_Database Migration_Database Concurrency - Fatal编程技术网

Postgresql 从选择插入未命中某些行-Postgres

Postgresql 从选择插入未命中某些行-Postgres,postgresql,database-migration,database-concurrency,Postgresql,Database Migration,Database Concurrency,我们有一个大约700万条ferrari类型记录的表,我们希望进行模式迁移。我们使用了这个脚本 insert into new_car id, name, type, colorType select id, name, type, 'red' from old_car where type = 'ferrari' order by id asc 脚本执行大约需要50分钟,完成后,我们意识到新车表的记录比旧车表少200万条。 当脚本执行old_car表时,仍然同时得

我们有一个大约700万条ferrari类型记录的表,我们希望进行模式迁移。我们使用了这个脚本

insert into new_car id, name, type, colorType
   select id, name, type, 'red' 
   from old_car 
   where type = 'ferrari' 
   order by id asc
脚本执行大约需要50分钟,完成后,我们意识到
新车
表的记录比
旧车
表少200万条。 当脚本执行
old_car
表时,仍然同时得到插入、更新等操作


这种并发是否会导致某种问题?缺少约2M行的可能原因是什么?(查询运行时,
old\u car
表没有得到2M次删除,可能是100次或200次删除)

语句插入了语句启动时
old\u car
中的行。当语句运行时,它看不到表中的更改。您只插入
“ferrari”
汽车,而不是所有汽车。。。你是不是很惊讶你只插入了500万?除非你在迪拜,否则我会说这太多了。顺便说一句,如果你查询花了50分钟,你可能没有一个
type
show-us
EXPLAIN-ANALYZE
@JuanCarlosOropeza表中有700万条法拉利
类型的记录,我已经在问题中修复了它@一匹没有名字的马在
旧车
表中没有2百万次删除,只有几次(100或200次)。我关心的不是执行死刑所花的时间。我担心缺少行。你不能在同一条评论上引用两个用户,你应该创建单独的评论,这样每个用户都会收到通知。正如@horse在您开始查询时所说的,db创建了表的快照,因此db上发生的事情不应该影响结果<代码>创建表格测试\从类型为“法拉利”的旧车中选择计数(*),然后从类型为“法拉利”的旧车中创建表格测试\从类型为“法拉利”的旧车中选择计数(*),并告诉我结果