小编aco*_*hen的帖子

使用JSON字段时的查询优化

在我的笔记本电脑上运行PostgreSQL 9.6.4,我有一个叫node有主键id字段和 properties::jsonb字段的表.

我在该properties字段上设置了GIN索引.

当我运行此查询时:

SELECT   n.*
FROM     node n
WHERE    node_type_id = '2'
AND      properties @> '{"slug":"wild-castles"}'::JSONB
ORDER BY n.id ASC OFFSET 0 LIMIT 10;
Run Code Online (Sandbox Code Playgroud)

在~5M行表上,获得答案大约需要20秒.查看解释计划,我发现查询优化器首先按主键对表进行排序,然后按properties字段过滤:

Limit  (cost=0.56..1517.94 rows=10 width=154)
  ->  Index Scan using node_pkey on node n  (cost=0.56..739571.11 rows=4874 width=154)
        Filter: ((properties @> '{"slug": "wild-castles"}'::jsonb) AND ((node_type_id)::text = '2'::text))
Run Code Online (Sandbox Code Playgroud)

但当我删除顺序时,我看到优化器使用索引按预期方式:

SELECT n.*
FROM   node n
WHERE  node_type_id = '2'
AND    properties @> '{"slug":"wild-castles"}'::JSONB
OFFSET 0 LIMIT 10;

Limit  (cost=93.77..127.10 …
Run Code Online (Sandbox Code Playgroud)

sql postgresql

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

自动选择视频缩略图

我们都听说过YouTube使用深度学习为用户视频选择代表性的缩略图。但是有没有人成功地在tensorflow上尝试过呢?

我确实找到了https://github.com/yahoo/hecate,它声称可以做到这一点,但是对结果的印象却不那么明显。使用ffmpeg提取关键帧,然后计算颜色分布以选择“最佳”图像,我实际上得到了更好的结果。

但是很想知道是否有人使用更多的“智能”算法来做得更好。

video machine-learning thumbnails tensorflow

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