小编Thi*_*yão的帖子

如何使用 Sql Azure 在 SSMS 对象浏览器上启用查询存储?

我正在遵循本指南:Monitoring Performance By Use the Query Store

  • 我正在使用 SSMS 2016 CTP3.2 和 Sql Azure V12
  • 我已在数据库属性上启用查询存储。
  • 我可以使用 azure 门户上的查询性能洞察。

但是,当我在 SMSS 2016 CTP3.2 上打开 Azure 数据库并展开数据库树时,查询存储/回归查询或任何其他选项都可用。

我希望能够进行 IO 消耗最多的查询并分析执行计划。

我还需要启用什么吗?

sys.databases中相关的is_query_store_on列显示 0,但数据库属性表明它已启用。我执行了,但is_query_store_on仍然保持在 0。ALTER DATABASE <DB> SET QUERY_STORE = ON;

以下查询:

SELECT 
    actual_state, actual_state_desc, readonly_reason, 
    current_storage_size_mb, max_storage_size_mb
FROM sys.database_query_store_options;
Run Code Online (Sandbox Code Playgroud)

显示实际状态= 2;

sql-server azure-sql-database sql-server-2016 query-store

5
推荐指数
1
解决办法
5238
查看次数

当我们更改计算机日期/时间时,postgresql 的 uuid_generate_v1() 可能会发生冲突吗?

根据postgresql uuid-ossp文档uuid_generate_v1()是基于Mac地址+时间戳:

https://www.postgresql.org/docs/9.4/static/uuid-ossp.html

在分布式数据库场景中,我们有数百个数据库使用 UUID 键生成记录并同步回中央数据库。

假设我们检测到一台机器将来的日期/时间错误,我们将其改回正确的日期/时间。它可能会在此特定计算机上生成冲突的 UUID 密钥吗?

一种情况是夏令时/夏令时。

postgresql random time uuid

5
推荐指数
1
解决办法
1604
查看次数

在 WHERE 子句中使用函数时查询速度变慢

这很快(49ms):

v_cpf_numerico := ext.uf_converte_numerico(new.nr_cpf);

select cd_cliente into v_cd_cliente
from central.cliente where nr_cpf_cnpj = v_cpf_numerico;
Run Code Online (Sandbox Code Playgroud)

这很慢(15 秒):

select cd_cliente into v_cd_cliente
from central.cliente where nr_cpf_cnpj = ext.uf_converte_numerico(new.nr_cpf);
Run Code Online (Sandbox Code Playgroud)

功能:

create or replace function ext.uf_converte_numerico(_input varchar(30)) returns bigint
as
$$
begin
    _input := regexp_replace(_input, '[^0-9]+', '', 'g');

    if _input = '' then
        return null;
    end if;

    return cast(_input as bigint);
end
$$ language plpgsql;
Run Code Online (Sandbox Code Playgroud)

我使用的是 PostgreSQL 12。
为什么第二个变体很慢?

postgresql performance functions postgresql-12 query-performance

5
推荐指数
1
解决办法
3352
查看次数