> For the complete documentation index, see [llms.txt](https://docs.postgresql.tw/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.postgresql.tw/19/appendixes/contrib/tsm-system-time.md). Agents can also search and read this documentation through its [MCP server](https://docs.postgresql.tw/~gitbook/mcp).

# F.47. tsm\_system\_time — TABLESAMPLE 的 SYSTEM\_TIME 取樣方法 \#

### F.47. tsm\_system\_time — `TABLESAMPLE` 的 `SYSTEM_TIME` 取樣方法 [#](#tsm-system-time) <a href="#tsm-system-time" id="tsm-system-time"></a>

[F.47.1. 範例](#tsm-system-time-examples)

`tsm_system_time` 模組提供資料表取樣方法 `SYSTEM_TIME`，可用於 [`SELECT`](https://docs.postgresql.tw/19/reference/sql-commands/sql-select.md) 命令的 `TABLESAMPLE` 子句。

此資料表取樣方法接受單一浮點數引數，表示讀取資料表時最多可花費的毫秒數。這讓你可以直接控制查詢所需的時間，代價是樣本的大小變得難以預測。產生的樣本會包含在指定時間內能讀取的所有資料列，除非整個資料表已先讀取完畢。

與內建的 `SYSTEM` 取樣方法一樣，`SYSTEM_TIME` 執行區塊層級的取樣，因此樣本並非完全隨機，而可能受到群聚效應影響，尤其是只選取少量資料列時。

`SYSTEM_TIME` 不支援 `REPEATABLE` 子句。

此模組被視為「受信任」，亦即具有目前資料庫 `CREATE` 權限的非超級使用者可以安裝它。

#### F.47.1. 範例 [#](#tsm-system-time-examples) <a href="#tsm-system-time-examples" id="tsm-system-time-examples"></a>

以下是使用 `SYSTEM_TIME` 選取資料表樣本的範例。首先安裝擴充功能：

```

CREATE EXTENSION tsm_system_time;
```

接著即可在 `SELECT` 命令中使用它，例如：

```

SELECT * FROM my_table TABLESAMPLE SYSTEM_TIME(1000);
```

此命令會傳回 `my_table` 在 1 秒（1000 毫秒）內所能讀取的最大樣本。當然，若整個資料表能在小於 1 秒的時間內讀完，就會傳回其所有資料列。

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/tsm-system-time.html)（原文版本：18.6；核對日期：2026-10-22）


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.postgresql.tw/19/appendixes/contrib/tsm-system-time.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
