日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

postgresql 排序索引

發(fā)布時(shí)間:2024/10/12 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 postgresql 排序索引 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

官方網(wǎng)站

In addition to simply finding the rows to be returned by a query, an index may be able to deliver them in a specific sorted order. This allows a query's?ORDER BY?specification to be honored without a separate sorting step. Of the index types currently supported by?PostgreSQL, only B-tree can produce sorted output — the other index types return matching rows in an unspecified, implementation-dependent order.

The planner will consider satisfying an?ORDER BY?specification either by scanning an available index that matches the specification, or by scanning the table in physical order and doing an explicit sort. For a query that requires scanning a large fraction of the table, an explicit sort is likely to be faster than using an index because it requires less disk I/O due to following a sequential access pattern. Indexes are more useful when only a few rows need be fetched. An important special case is?ORDER BY?in combination with?LIMIT?n: an explicit sort will have to process all the data to identify the first?n?rows, but if there is an index matching the?ORDER BY, the first?n?rows can be retrieved directly, without scanning the remainder at all.

By default, B-tree indexes store their entries in ascending order with nulls last. This means that a forward scan of an index on column?x?produces output satisfying?ORDER BY x?(or more verbosely,?ORDER BY x ASC NULLS LAST). The index can also be scanned backward, producing output satisfying?ORDER BY x DESC?(or more verbosely,?ORDER BY x DESC NULLS FIRST, since?NULLS FIRST?is the default forORDER BY DESC).

You can adjust the ordering of a B-tree index by including the options?ASC,?DESC,?NULLS FIRST, and/or?NULLS LAST?when creating the index; for example:

CREATE INDEX test2_info_nulls_low ON test2 (info NULLS FIRST); CREATE INDEX test3_desc_index ON test3 (id DESC NULLS LAST);

An index stored in ascending order with nulls first can satisfy either?ORDER BY x ASC NULLS FIRST?or?ORDER BY x DESC NULLS LAST?depending on which direction it is scanned in.

You might wonder why bother providing all four options, when two options together with the possibility of backward scan would cover all the variants of?ORDER BY. In single-column indexes the options are indeed redundant, but in multicolumn indexes they can be useful. Consider a two-column index on?(x, y): this can satisfy?ORDER BY x, y?if we scan forward, or?ORDER BY x DESC, y DESC?if we scan backward. But it might be that the application frequently needs to use?ORDER BY x ASC, y DESC. There is no way to get that ordering from a plain index, but it is possible if the index is defined as?(x ASC, y DESC)?or?(x DESC, y ASC).

Obviously, indexes with non-default sort orderings are a fairly specialized feature, but sometimes they can produce tremendous speedups for certain queries. Whether it's worth maintaining such an index depends on how often you use queries that require a special sort ordering.

?

默認(rèn)索引是B樹索引,因?yàn)锽樹本來(lái)就是排序樹,所以有索引的列會(huì)默認(rèn)排序asc nulls last,然后我們?cè)O(shè)排序的時(shí)候只是設(shè)置asc/desc,nulls first/nulls last

轉(zhuǎn)載于:https://www.cnblogs.com/cdyboke/p/7090354.html

總結(jié)

以上是生活随笔為你收集整理的postgresql 排序索引的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 精久久| 91天堂视频 | 成年人黄色一级片 | 久久天天躁狠狠躁夜夜av | 婷婷色在线观看 | mm131美女大尺度私密照尤果 | 丰满饥渴老女人hd | 国产乱码一区二区三区 | 国产主播啪啪 | 中文字幕色片 | 国产自产视频 | 新版红楼梦在线高清免费观看 | 淫片网站 | 人人曰 | missav|免费高清av在线看 | 久久成人久久 | 午夜不卡久久精品无码免费 | 狠狠狠狠狠狠干 | 欧美国产高潮xxxx1819 | 欧美性大战久久久久久久 | 亚洲一区二区观看 | 精品一性一色一乱农村 | 成年人晚上看的视频 | 大尺度叫床戏做爰视频 | 亚洲操| 国内精品小视频 | 日本一级淫片免费放 | 综合图区亚洲 | www.午夜视频 | 欧美区一区| 天天干干 | 亚洲一本之道 | 国产情侣自拍一区 | 玖玖玖国产精品 | 国内一区二区 | 黄瓜视频色版 | 精品96久久久久久中文字幕无 | 亚洲精品网址 | 亚洲欧美国产一区二区三区 | 久久亚洲AV无码 | 秋霞欧美一区二区三区视频免费 | 成人h动漫精品一区二区无码 | 毛片视频网站在线观看 | 国产大片一区 | 456亚洲视频 | 亚洲欧美一二三区 | 欧美日韩视频一区二区 | 中文字幕在线视频一区 | 国产一区91| 丰满少妇在线观看资源站 | 被扒开腿一边憋尿一边惩罚 | 一区二区三区四区久久 | 精品视频久久久久久久 | 天天插天天操 | 爱av在线 | 久久国内免费视频 | 自拍中文字幕 | 日本久久网站 | 久久美女精品 | 91香蕉视频污污 | www激情 | 久草欧美 | 美女又黄又爽 | 麻豆一区产品精品蜜桃的特点 | 天天摸天天舔天天操 | 成人性生交大片免费看r链接 | 青青青草国产 | 亚州av一区二区 | 天天舔天天爽 | 少妇偷人精品无码人妻 | 国产激情一区二区三区四区 | 中文字幕免费高清网站 | 日韩一区二区三 | 91av在线免费 | 夫妻自拍偷拍 | 国产在线看 | 色丁香久久 | 午夜影院入口 | 体内射精一区二区 | 秋霞午夜视频 | 中文字幕三级电影 | 青青青国产视频 | 久久综合干 | 波多野结衣一区在线 | 日本国产在线观看 | 亚洲色图欧美视频 | 成人毛片100部免费看 | 蜜桃精品噜噜噜成人av | 成年人国产精品 | 黄色小视频免费在线观看 | 欧美色涩在线第一页 | 久久九精品 | 亚洲自拍第二页 | wwwwww在线观看 | 欧美久久久久久久久久久久久久 | 成人激情小视频 | 蜜桃av噜噜一区二区三区网址 | 伊人网色 | 色站在线 |