Skip to content
Database

数据库配置

Updating the default configuration for your Postgres database.

Postgres 为你的数据库大小提供了一套合理的默认值。在某些情况下,这些默认值可以被更新。除非你非常了解自己在做什么,否则我们不建议更改这些默认值。

🌐 Postgres provides a set of sensible defaults for you database size. In some cases, these defaults can be updated. We do not recommend changing these defaults unless you know what you're doing.

超时 #

🌐 Timeouts

查看 Timeouts 部分。

🌐 See the Timeouts section.

语句优化 #

🌐 Statement optimization

所有 Supabase 项目都安装了 pg_stat_statements 扩展,它会跟踪对其执行的所有语句的计划和执行统计信息。这些统计信息可以用来诊断你项目的性能。

🌐 All Supabase projects come with the pg_stat_statements extension installed, which tracks planning and execution statistics for all statements executed against it. These statistics can be used in order to diagnose the performance of your project.

这些数据还可以结合 Postgres 的 explain 功能来优化你的使用。

🌐 This data can further be used in conjunction with the explain functionality of Postgres to optimize your usage.

管理时区 #

🌐 Managing timezones

每个 Supabase 数据库默认都是设置为 UTC 时区的。即使你的用户在不同的地方,我们也强烈建议保持这种设置。因为如果你采用“数据库里的所有时间都是 UTC 时间”的思维模式,计算不同时区之间的差异会容易得多。

🌐 Every Supabase database is set to UTC timezone by default. We strongly recommend keeping it this way, even if your users are in a different location. This is because it makes it much easier to calculate differences between timezones if you adopt the mental model that everything in your database is in UTC time.

更改时区 #

🌐 Change timezone

1
alter database postgres
2
set timezone to 'America/New_York';

时区完整列表 #

🌐 Full list of timezones

获取你的数据库支持的所有时区列表。这将返回以下列:

🌐 Get a full list of timezones supported by your database. This will return the following columns:

  • name:时区名称
  • abbrev:时区缩写
  • utc_offset:与 UTC 的时差(正数表示格林威治以东)
  • is_dst:如果目前正在实行夏时制,则为真
1
select name, abbrev, utc_offset, is_dst
2
from pg_timezone_names()
3
order by name;

搜索特定时区 #

🌐 Search for a specific timezone

使用 ilike(不区分大小写搜索)来查找特定时区。

🌐 Use ilike (case insensitive search) to find specific timezones.

1
select *
2
from pg_timezone_names()
3
where name ilike '%york%';