跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • 要 update 个 3000W 行的大表做数据 migration,怎么操作比较好
未分類
13 5 月 2020

要 update 个 3000W 行的大表做数据 migration,怎么操作比较好

要 update 个 3000W 行的大表做数据 migration,怎么操作比较好

資深大佬 : rockyou12 53

数据库是 postgresql,以前经纬度用的单独字段,现在像用 point 类型再加 postgis 做分析。表有优化,相当于做了表分区,现在 sql 是

update t_gps set location = ST_GeomFromText('Point(' || "lont" || ' ' || "lat" || ')', 4326); create index idx_gps_location on t_gps using gist ("location"); 

但在测试库试了下,真的很慢。一般这种更新方案怎么做比较好?

大佬有話說 (4)

  • 資深大佬 : nandaye

    create table test as select t_gps.*,ST_GeomFromText(‘Point(‘ || “lont” || ‘ ‘ || “lat” || ‘)’, 4326) as location from t_gps;
    drot table t_gps;
    rename test to t_gps;

  • 主 資深大佬 : rockyou12

    @nandaye 感谢,思路懂了

  • 資深大佬 : dswyzx

    @nandaye 跟建索引一个套路哇.

  • 資深大佬 : duhui

    drot table t_gps; 改成 rename t_gps to t_gps_bak; 比较好吧

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具