我正在尝试将 C# 应用程序 (+EF6) 使用的 SQL Server DB 移动到 Postgres 12,但我在进行不区分大小写的字符串比较方面运气不佳。现有的 SQL Server 数据库使用 SQL_Latin1_General_CP1_CI_AS 排序规则,这意味着所有 WHERE 子句都不必担心大小写。
我知道 CIText 以前是这样做的,但现在被非确定性排序规则所取代。
我创建了这样一个排序规则;
CREATE COLLATION ci (provider = icu, locale = 'und-u-ks-level2', deterministic = false);
Run Code Online (Sandbox Code Playgroud)
并且当它以每列为基础应用于 CREATE TABLE 时,它确实有效 - 忽略大小写。
CREATE TABLE casetest (
id serial NOT NULL,
code varchar(10) null COLLATE "ci",
CONSTRAINT "PK_id" PRIMARY KEY ("id"));
Run Code Online (Sandbox Code Playgroud)
但是从我读过的内容来看,它必须应用于每个 varchar 列,并且不能在整个数据库中全局设置。
这样对吗?
由于杂乱,我不想在任何地方使用 .ToLower() 并且不会使用列上的任何索引。
我尝试修改 pg_collation 中预先存在的“默认”排序规则以匹配“ci”排序规则的设置,但没有效果。
提前致谢。PG
我想使用 ICU 系统不敏感的排序规则,以避免 postgres11-on-mac 与 postgres11-on-Ubuntu 之间的排序差异。我的第一个测试是转储现有的Collate=en_US.UTF-8并将它们 pg_restore 到使用创建的数据库中Collate=en-US-x-icu
创建数据库文档有这样的内容:
要创建具有不同语言环境的数据库音乐:
创建数据库音乐 LC_COLLATE 'sv_SE.utf8' LC_CTYPE 'sv_SE.utf8' 模板 template0;
select collname, collprovider from pg_collation where collname like 'en_US%';
collname | collprovider
------------------------+--------------
en_US.UTF-8 | c
en_US | c
en_US.ISO8859-15 | c
en_US.ISO8859-1 | c
en_US | c
en_US | c
en-US-x-icu | i
en-US-u-va-posix-x-icu | i
(8 rows)
Run Code Online (Sandbox Code Playgroud)
但使用任一 icu 语言环境创建数据库时都没有运气。
CREATE DATABASE test LC_COLLATE = 'en-US-x-icu' TEMPLATE template0;
ksysdb=# CREATE DATABASE test LC_COLLATE …Run Code Online (Sandbox Code Playgroud) 我想知道 x**2 还是 x*x 更快
def sqr(x):
for i in range (20):
x = x**2
return x
def sqr_(x):
for i in range (20):
x = x*x
return x
Run Code Online (Sandbox Code Playgroud)
当我计时时,这就是我得到的:
The time it takes for x**2: 101230500
The time it takes for x*x: 201469200
Run Code Online (Sandbox Code Playgroud)
我已经尝试了很多很多次,它们要么相等,要么 x ** 2 比 x * x 快。但 x*x 永远不会比 x**2 快。
所以我反驳了代码:
对于 x**2:
5 12 LOAD_FAST 0 (x)
14 LOAD_CONST 2 (2)
16 BINARY_POWER
18 STORE_FAST 0 (x)
20 JUMP_ABSOLUTE 8
Run Code Online (Sandbox Code Playgroud)
对于 x*x: …
下面看起来很多,但主要只是输出。
我正在尝试使用 multer (通过 iPhone 上的 Alamofire 发送包含视频(.mov 格式)的请求)作为输入的缓冲区,然后我希望它作为缓冲区输出,然后将结果发送到S3。我想我已经很接近了,但我不认为 Fluent-ffmpeg 可以传入缓冲区。这是使用此构建包部署在 Heroku 上的: https: //github.com/jonathanong/heroku-buildpack-ffmpeg-latest。 …… 我如何正确地传递它?
const multer = require('multer')
const upload = multer({ limits: { fieldSize: 100_000_000 } })
app.post('/create', upload.single('video'), async function (request, response, next) {
let data = request.body
console.log(data) // prints [Object: null prototype] { param1: '' }
let bufferStream = new stream.PassThrough();
console.log(request.file.buffer) // prints '<Buffer 00 00 00 14 66 74 79 70 71 74 20 20 00 00 00 00 71 …Run Code Online (Sandbox Code Playgroud) collation ×2
icu ×2
locale ×2
postgresql ×2
assembly ×1
javascript ×1
mp4 ×1
node.js ×1
performance ×1
python ×1
time ×1