小编gre*_*van的帖子

为什么真空分析改变查询计划而分析没有?

我想在Postgres中利用仅索引扫描的强大功能,并尝试使用一个表:

CREATE TABLE dest.contexts
(
  id integer NOT NULL,
  phrase_id integer NOT NULL,
  lang character varying(5) NOT NULL,
  ranking_value double precision,
  index_min integer,
  index_max integer,
  case_sensitive boolean,
  is_enabled boolean,
  is_to_sync boolean NOT NULL DEFAULT true
);

insert into dest.contexts select * from source.contexts;

alter table dest.contexts
  add constraint pk_contexts primary key (id, phrase_id, lang);

 CREATE INDEX idx_contexts_
  ON dest.contexts
  USING btree
  (id, is_enabled, lang, phrase_id, ranking_value, index_min, index_max, case_sensitive);
Run Code Online (Sandbox Code Playgroud)

索引涵盖了我想在下一个查询中使用的所有列:

explain analyze
select ranking_value, index_min, index_max, case_sensitive
from dest.contexts
where …
Run Code Online (Sandbox Code Playgroud)

postgresql vacuum sql-execution-plan postgresql-9.4 autovacuum

8
推荐指数
1
解决办法
347
查看次数

Kusto中​​有字符串格式化功能吗?

我正在努力在标量函数列表中找到它。有没有比strcat()Kusto 中的字符串格式化更方便的方法?

kql azure-data-explorer

6
推荐指数
1
解决办法
3089
查看次数

如何取消任务但等到它完成?

我有线程任务,它在循环中执行一些操作:

static void TaskAction(CancellationToken ct)
{
    while (SomeCondition())
    {
        DoSomeSeriousJob();
        ct.ThrowIfCancellationRequested();
    }
}

static void DoSomeSeriousJob()
{
    Console.WriteLine("Serious job started");
    Thread.Sleep(5000);
    Console.WriteLine("Serious job done");
}
Run Code Online (Sandbox Code Playgroud)

我启动它然后在一段时间后取消:

    var cts = new CancellationTokenSource();
    var task = Task.Factory.StartNew(() => TaskAction(cts.Token), cts.Token);
    Thread.Sleep(1000);
    cts.Cancel();
Run Code Online (Sandbox Code Playgroud)

这个操作必须正确完成,我不想打断它.但是我想向我的任务发送取消请求并等到它正确完成(我的意思是它在代码中得到了某些点).我尝试了以下方法:

1.等待(CancellationToken ct)

try
{
    task.Wait(cts.Token);
}
catch (OperationCanceledException)
{
    Console.WriteLine("Task cancelled");
}
// Must be joined here.
Run Code Online (Sandbox Code Playgroud)

在这种情况下,程序立即返回Wait().任务继续运行,ThrowIfCancellationRequested()但如果主线程退出任务也会中断.

2.等待()

try
{
    task.Wait();
}
catch (OperationCanceledException)
{
    Console.WriteLine("Task cancelled");
}
catch (Exception …
Run Code Online (Sandbox Code Playgroud)

.net c# multithreading task-parallel-library

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

由于磁盘写入错误,Tarantool 无法启动

我正在尝试从头开始在 Docker 中启动 Tarantool(没有现有数据)。我使用他们在教程中建议的 Docker 命令并在 MacOS 10.15.6 (Catalina) 上的 Docker Desktop 2.4.0.0 下运行它:

docker run \
  --name mytarantool \
  -d -p 3301:3301 \
  -v /data/dir/on/host:/var/lib/tarantool \
  tarantool/tarantool:2.5.1
Run Code Online (Sandbox Code Playgroud)

/data/dir/on/host替换为我在笔记本电脑上的本地目录)。我也用最新版本 2.6.0 尝试过。

容器在启动后很快终止。docker logs显示这个:

2020-10-02 20:51:10.331 [1] main/103/tarantool-entrypoint.lua C> Tarantool 2.6.0-0-g47aa4e01e
2020-10-02 20:51:10.331 [1] main/103/tarantool-entrypoint.lua C> log level 5
2020-10-02 20:51:10.332 [1] main/103/tarantool-entrypoint.lua I> mapping 268435456 bytes for memtx tuple arena...
2020-10-02 20:51:10.332 [1] main/103/tarantool-entrypoint.lua I> mapping 134217728 bytes for vinyl tuple arena...
2020-10-02 20:51:10.335 …
Run Code Online (Sandbox Code Playgroud)

docker tarantool

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

聚集索引和非聚集索引之间的性能差异

我在数据库中找到一个表,在同一列上有两个单独的索引。列类型为,int并且此列上有一个集群主键。除此之外,同一列上还有一个唯一的非聚集索引。索引具有相同的选项(排序方向和其他方向),并且不包含任何包含的列。

该索引由其他一些表中的外键约束使用,因此,如果不重新创建外键约束,则无法删除该索引。

可能有任何理智的理由吗?

sql-server indexing sql-server-2012

2
推荐指数
1
解决办法
771
查看次数

goroutine 可以在什么时候产生?

我试图更好地了解 Go 程序中 goroutines 是如何调度的,尤其是在它们可以让步给其他 goroutines 的时候。我们知道 goroutine 会产生会阻塞它的 syscals,但显然这不是全部。

这个问题引起了一些类似的担忧,最受好评的答案是 goroutine 也可能打开函数调用,因为这样做会调用调度程序来检查堆栈是否需要增长,但它明确表示

如果你没有任何函数调用,只是一些数学运算,那么是的,goroutine 会锁定线程,直到它退出或遇到可能让其他人执行的东西。

我写了一个简单的程序来检查和证明:

package main

import "fmt"

var output [30]string      // 3 times, 10 iterations each.
var oi = 0

func main() {
    runtime.GOMAXPROCS(1)   // Or set it through env var GOMAXPROCS.
    chanFinished1 := make(chan bool)
    chanFinished2 := make(chan bool)

    go loop("Goroutine 1", chanFinished1)
    go loop("Goroutine 2", chanFinished2)
    loop("Main", nil)

    <- chanFinished1
    <- chanFinished2

    for _, l := range output {
        fmt.Println(l)
    }
}

func loop(name …
Run Code Online (Sandbox Code Playgroud)

go green-threads

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