Skip to content

Introducing functions COST for more parallel operations? #16

@Thammachart

Description

@Thammachart

We tried using this query below to generate 5+ million records with nanoid, but got stuck by this error cannot start commands during a parallel operation

INSERT INTO __map_table__(old,new)
SELECT id, nanoid() FROM __old_table__;

we resolve this by introducing COST lower than or equal to 50

...
    RETURNS text -- A randomly generated NanoId String
    LANGUAGE plpgsql
    VOLATILE
    PARALLEL SAFE
    COST 10 -- added
...

I'm not an expert on this, so is this a legit solution to solve this kind of problem or is there another way?
If this is good enough, I'll create PR.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingquestionFurther information is requestedwaiting for contributorWaiting for updates by the contributor

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions