mkvcvc
mkvcvc

Reputation: 1565

HSQL simple one column update runs forever

I have a database with about 125 000 rows, each row with primary key, couple of int columns and couple of varchars.
I've added an int column and I'm trying to populate it before adding not null constraint.

The db is persisted in script file. I've read somewhere that all the affected rows get loaded to memory before the actual update, which means there wont be a disk write for every row. The whole db is about 20MB which would mean loading it and doing the update should be reasonably fast, right?

So, no joins, no nested queries, basic update. I've tried multiple db managers including the one bundled with hsql jar.

update tbl1 set col1 = 1

Query never finishes executing.

Upvotes: 0

Views: 246

Answers (1)

fredt
fredt

Reputation: 24372

It is probably running out of memory.

The easier way to do this operation is to define the column with DEFAULT 1, which does not use much memory regardless of the size of the table. You can even add the not null constraint at the same time

ALTER TABLE T ADD COLUMN C INT DEFAULT 1 NOT NULL

Upvotes: 1

Related Questions