<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                > ctid表示數據行在它所處的表內的物理位置,ctid字段的類型是tid。 > 雖然ctid可以快速定位到數據行,但是在每次執行`vaccum full`命令之后,數據行在塊內的物理位置就會發生變化,所以ctid并不能作為長期的數據行標識符,應該使用主鍵來標識一個邏輯行 ``` // 查看ctid // 格式(blockid,itemid):如(0,1);0表示塊id;1表示在這塊第一條記錄 postgres=# select ctid,id from test limit 10; ctid | id --------+---- (0,1) | 1 (0,2) | 2 (0,3) | 3 (0,4) | 4 (0,5) | 5 (0,6) | 6 (0,7) | 7 (0,8) | 8 (0,9) | 9 (0,10) | 10 (10 rows) ``` **ctid 的作用:** 1、用于去重,相當于oracle中的偽列 rowid ``` postgres=# select ctid,* from test; ctid | id | name | remark -------+----+-------+------- (0,1) | 2 | xx | ss (0,4) | 3 | dd | ss (0,5) | 4 | xs | aa (3 rows) postgres=# delete from test where ctid not in (select min(ctid) from test group by remark); DELETE 1 postgres=# select ctid,* from test; ctid | id | name | remark -------+----+-------+------- (0,1) | 2 | xx | ss (0,5) | 4 | xs | aa (2 rows) // 刪除成功后,重新插入一條數據 postgres=# insert into test values(3,'aa','asd'); INSERT 0 1 postgres=# select ctid,* from test; ctid | id | name | remark -------+----+-------+------- (0,1) | 2 | xx | ss (0,5) | 4 | xs | aa (0,6) | 3 | aa | asd (3 rows) ``` 可以看到,在刪除ctid為(0,4)后重新插入一條數據,新數據的ctid為(0,6),而不是剛剛刪除的(0,4)。這是因為pgsql的特性:刪除元祖占據的存儲空間并沒有被回收,直到執行vaccum命令之后(postgresql里面有AUTOVACUUM進程;也可以手動回收) 2、使用系統表pg_class,查看表占用的總塊數,其中relpages,reltuples分別代表塊數,記錄數! ``` postgres=# select relpages,reltuples from pg_class where relname = 'test'; relpages | reltuples ----------+----------- 637 | 100000 (1 row) ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看