简体   繁体   English

MonetDB 创建 100.000 列

[英]MonetDB create 100.000 columns

I am trying to create a MonetDB database that shall hold 100k columns and approximately 2M rows of smallint type.我正在尝试创建一个 MonetDB 数据库,该数据库应包含 100k 列和大约 2M 行的 smallint 类型。

To generate 100k columns I am using a C code, ie, a loop that performs the following sql request:要生成 100k 列,我使用了 C 代码,即执行以下 sql 请求的循环:

ALTER TABLE test ADD COLUMN s%d SMALLINT;

where %d is a number from 1 till 100000.其中 %d 是从 1 到 100000 的数字。

I observed that after 80000 sql requests each transaction takes about 15s, meaning that I need a lot of time to complete the table creation.我观察到在 80000 个 sql 请求之后,每个事务大约需要 15s,这意味着我需要大量时间来完成表创建。

Could you tell me if there is a simple way of creating 100k columns?你能告诉我是否有一种简单的方法来创建 100k 列吗?

Also, do you know what exactly what is going on with MonetDB?另外,您知道 MonetDB 到底发生了什么吗?

You should use only one create table您应该只使用一个创建表

in script shell (bash) :在脚本外壳(bash)中:

#!/bin/bash

fic="/tmp/100k.sql"


col=1

echo "CREATE TABLE bigcol (" > $fic

while [[ $col -lt 100000 ]]
do
    echo "field$col SMALLINT," >> $fic

    col=$(($col + 1))

done

echo "field$col SMALLINT);" >> $fic

And in command line :并在命令行中:

sh 100k.sh
mclient yourbdd < /tmp/100k.sql

wait about 2 minutes :D等待大约 2 分钟 :D

mclient yourbdd
> \d bigcol
[ ... ... ...]
    "field99997"  SMALLINT,
    "field99998"  SMALLINT,
    "field99999"  SMALLINT,
    "field100000" SMALLINT
);

DROP TABLE bigcol is against very very long. DROP TABLE bigcol 反对很长很长。 I do not know why.我不知道为什么。

I also think it is not a good idea, but it answer your question.我也认为这不是一个好主意,但它回答了你的问题。

Pierre皮埃尔

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM