SQL UPDATE #1270
-
Given two files which should but are not guaranteed to be of equal lengths as they are generated after another (DomainsInclude.csv and DomainsExclude.csv) I need to set a column The following CSVQ command works but is of course extremely slow with 20000 lines (with or without the ORDER): UPDATE DomainsInclude
SET eppstatus = (
SELECT DomainsExclude.eppstatus
FROM DomainsExclude
WHERE DomainsInclude.name = DomainsExclude.name
ORDER BY DomainsExclude.name
);
COMMIT; Is there a
|
Beta Was this translation helpful? Give feedback.
Replies: 10 comments 44 replies
-
Hi @ondohotola , I can think of two solutions:
First, do the SELECT with sqlp: qsv sqlp DomainExclude.csv DomainsInclude.csv \
"select DomainsExclude.name, DomainsExclude.appstatus \
FROM DomainsExclude, DomainsInclude \
WHERE DomainsInclude.name = DomainsExclude.name \
ORDER BY DomainsExclude.name" \
--output DE_appstatus.csv and then qsv joinp name DomainsInclude.csv name DE_appstatus.csv --output joined_with_appstatus.csv
Create a SQL script named Domains.sql: -- first, create a table from the select
CREATE TABLE DomainsExclude_AppStatus as
SELECT DomainsExclude.name, DomainsExclude.appstatus
FROM DomainsExclude, DomainsInclude
WHERE DomainsInclude.name = DomainsExclude.name
ORDER BY DomainsExclude.name;
-- then we do the join with the just created table
SELECT *
FROM DomainsInclude JOIN DomainsExclude_AppStatus
ON DomainsInclude.name = DomainsExclude_AppStatus.name; and then run it with sqlp: qsv sqlp DomainsExclude.csv DomainsInclude.csv Domains.sql --output Domains_Appstatus.csv Let me know if either of this works and how fast it is compared with CSVQ. |
Beta Was this translation helpful? Give feedback.
-
option 1 takes seconds :-)-O (`csvq` takes 3 minutes) thank you very much
|
Beta Was this translation helpful? Give feedback.
-
Ok,
will measure later in the PM.
|
Beta Was this translation helpful? Give feedback.
-
Can you share any sample data files? |
Beta Was this translation helpful? Give feedback.
-
Too much work, almost 100 columns and almost all of them GDPR'ed.
|
Beta Was this translation helpful? Give feedback.
-
Can you propose some command?
|
Beta Was this translation helpful? Give feedback.
-
didn't try
|
Beta Was this translation helpful? Give feedback.
-
Two commands if you count |
Beta Was this translation helpful? Give feedback.
-
That _right is rather helpful, actually.
|
Beta Was this translation helpful? Give feedback.
-
It might be interesting to know that since SELECT
DISTINCT clients.Name as `COMPANY NAME`,
clients.`Client ID` as `Client Identifier`,
clients.`E-mail` as `Main E-mail`,
"no" as `Connect via EPP`,
clients.Country as Country,
clients.Phone as Phone,
clients.`Admin Contact` as `Administrative Contact`,
clients.`E-mail` as `Administrative E-mail`
FROM
Clients clients
WHERE
EXISTS ( SELECT 1
FROM DomainsInclude domains
WHERE clients.`Client ID` = domains.`registrar_id` )
ORDER BY
clients.Name,
clients.`Client ID` which on a small Last night I was bored and figured out |
Beta Was this translation helpful? Give feedback.
Hi @ondohotola , I can think of two solutions:
sqlp
withjoinp
:First, do the SELECT with sqlp:
and then
joinp
it with DomainsIncludesqlp
operation..Create a SQL script named Domains.sql: