小编sim*_*imo的帖子

搜索数组性能?

我们有一张桌子

id|school_id|parent_ids
Run Code Online (Sandbox Code Playgroud)

其中parent_ids是 id 数组。

如果我们没有school_idand onlyparent_id来搜索,那么查询将搜索数组中的所有表行parent_ids,可能有数千行,并且parent_id实际上可能只在其中的几行中。

在这种情况下,在查询数组列时使用 IN 是否会成为性能障碍?

编辑

这是表结构的转储:

-- ----------------------------
-- Table structure for schools_messages
-- ----------------------------
DROP TABLE IF EXISTS "public"."schools_messages";
CREATE TABLE "public"."schools_messages" (
  "id" int4 NOT NULL DEFAULT nextval('schools_messages_id_seq'::regclass),
  "message" jsonb NOT NULL DEFAULT '[]'::jsonb,
  "details" jsonb NOT NULL DEFAULT '[]'::jsonb,
  "school_id" int4 NOT NULL,
  "created_at" timestamp(0),
  "updated_at" timestamp(0),
  "parents_ids" int4[] DEFAULT ARRAY[]::integer[]
)
;
ALTER TABLE "public"."schools_messages" OWNER TO "prod_schools";

-- ---------------------------- …
Run Code Online (Sandbox Code Playgroud)

postgresql performance array

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

为什么我得到 NoHostAvailable:?

如果我运行这个简单的查询:

SELECT * from myapp.latests WHERE organization_id = 1 and user_id = 1;
Run Code Online (Sandbox Code Playgroud)

我得到错误:

NoHostAvailable:
Run Code Online (Sandbox Code Playgroud)

运行nodetool status结果:

Datacenter: eu-central
======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address    Load       Tokens       Owns (effective)  Host ID                               Rack
UN  10.0.0.53  190.96 KiB  256          0.0%              80f8bf0a-c46d-41ce-bb2e-498def5b3792  1a
UN  10.0.20.5  189.35 KiB  256          0.0%              f25fe4bf-29b2-4403-8e3e-4e973a5f26ab  1b
UN  10.0.0.54  183.13 KiB  256          0.0%              c46ac05a-6cb2-48f1-a776-2c57c33e7719  1a
Run Code Online (Sandbox Code Playgroud)

这是描述:

DESCRIBE myapp;

CREATE KEYSPACE myapp WITH replication = {'class': 'NetworkTopologyStrategy', 'eu-central-1': '2'}  AND durable_writes = true;

CREATE TABLE myapp.locations (
    organization_id …
Run Code Online (Sandbox Code Playgroud)

cassandra

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

计算行的存储大小?

在多租户只有一个DB中,使用一列来隔离客户数据,即customer_id。

是否可以在所有表​​中获取某个客户的存储大小?

postgresql

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

标签 统计

postgresql ×2

array ×1

cassandra ×1

performance ×1