我正在使用postgresql 9.0 beta 4.
将大量数据插入分区表后,我发现了一个奇怪的事情。当我查询表时,我可以在'not-null'字段中看到一个空类值为空的行。
奇怪的查询结果如下所示。
第689行是空的。前3个字段(stid,d,ticker)正在构成主键。所以他们不应该是空的。我使用的查询就是这个。
select * from st_daily2 where stid=267408 order by d
我甚至可以根据这些数据进行分组。
select stid, date_trunc('month', d) ym, count(*) from st_daily2
where stid=267408 group by stid, date_trunc('month', d)
'group by'结果仍然是空行。
第一行是空的。 但是,如果我查询'stid'或'd'为null,那么它什么也不返回。
这是postgresql 9b4的错误吗?或者一些数据损坏?
编辑:
我添加了我的表定义。
CREATE TABLE st_daily
(
stid integer NOT NULL,
d date NOT NULL,
ticker character varying(15) NOT NULL,
mp integer NOT NULL,
settlep double precision NOT NULL,
prft integer NOT NULL,
atr20 double precision NOT NULL,
upd timestamp with time zone,
ntrds double precision
)
WITH (
OIDS=FALSE
);
CREATE TABLE st_daily2
(
CONSTRAINT st_daily2_pk PRIMARY KEY (stid, d, ticker),
CONSTRAINT st_daily2_strgs_fk FOREIGN KEY (stid)
REFERENCES strgs (stid) MATCH SIMPLE
ON UPDATE CASCADE ON DELETE CASCADE,
CONSTRAINT st_daily2_ck CHECK (stid >= 200000 AND stid < 300000)
)
INHERITS (st_daily)
WITH (
OIDS=FALSE
);
此表中的数据是模拟结果。用c#编写的多线程多模拟引擎使用Npgsql将数据插入数据库。
psql也会显示空行。
答案 0 :(得分:1)
您最好在http://www.postgresql.org/support/submitbug
留言有些问题:
答案 1 :(得分:1)
你的问题的答案很可能在于你的第一句话:
我正在使用postgresql 9.0 beta 4。
你为什么这样做?升级到稳定版本。 Preferably the latest point-release of the current version. 截至今天,这是 9.1.4 。
答案 2 :(得分:0)
我得到了同样的观点:“那个空白值是什么?”
不,它不是NULL
,而是-infinity
。
要过滤这样的行使用:
WHERE
case when mytestcolumn = '-infinity'::timestamp or
mytestcolumn = 'infinity'::timestamp
then NULL else mytestcolumn end IS NULL
而不是:
WHERE mytestcolumn IS NULL