sql >> データベース >  >> RDS >> PostgreSQL

PostgreSQLUUIDタイプのパフォーマンス

    約30k行のテーブルがあり、(特定の無関係なアーキテクチャ上の理由で)UUIDがテキストフィールドに格納され、インデックスが付けられていました。クエリのパフォーマンスが予想よりも遅いことに気づきました。新しいUUID列を作成し、テキストuuid主キーにコピーして、以下で比較しました。 2.652ms対0.029ms。かなりの違い!

     -- With text index
        QUERY PLAN
        Index Scan using tmptable_pkey on tmptable (cost=0.41..1024.34 rows=1 width=1797) (actual time=0.183..2.632 rows=1 loops=1)
          Index Cond: (primarykey = '755ad490-9a34-4c9f-8027-45fa37632b04'::text)
        Planning time: 0.121 ms
        Execution time: 2.652 ms
    
        -- With a uuid index 
        QUERY PLAN
        Index Scan using idx_tmptable on tmptable (cost=0.29..2.51 rows=1 width=1797) (actual time=0.012..0.013 rows=1 loops=1)
          Index Cond: (uuidkey = '755ad490-9a34-4c9f-8027-45fa37632b04'::uuid)
        Planning time: 0.109 ms
        Execution time: 0.029 ms
    


    1. サーバーにデプロイした後にデータベースを更新するときにエラーが発生しました。 Laravel 5

    2. Oracle ISNULL()と同等

    3. エラーを引き起こすトランザクションのMYSQLIfステートメント

    4. VS2019とMySQLEntityFrameworkのデータベース名が重複しています