From dfac729daa4e9802391ddf3a15f16aa96e1a1a0e Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Thu, 14 Sep 2017 15:35:45 +0200 Subject: [PATCH] Refrain from querying the catalogs again. When we already have the information in the pgloader internal catalogs, don't issue another MySQL query. In this case, it's been used to fetch the list of columns and their data types so that we can choose to send either `colname` or maybe astext(`colname`) as `colname` for some geographic types. That's one less MySQL query per table. --- src/sources/mysql/mysql-schema.lisp | 15 +++++---------- src/sources/mysql/mysql.lisp | 2 +- src/sources/mysql/sql/get-column-list.sql | 6 ------ 3 files changed, 6 insertions(+), 17 deletions(-) delete mode 100644 src/sources/mysql/sql/get-column-list.sql diff --git a/src/sources/mysql/mysql-schema.lisp b/src/sources/mysql/mysql-schema.lisp index 4fa3e82..0e79a31 100644 --- a/src/sources/mysql/mysql-schema.lisp +++ b/src/sources/mysql/mysql-schema.lisp @@ -247,17 +247,12 @@ (:linestring (format nil "astext(`~a`) as `~a`" name name)) (t (format nil "`~a`" name)))) -(defun get-column-list (dbname table-name) +(defun get-column-list (copy) "Some MySQL datatypes have a meaningless default output representation, we - need to process them on the SQL side (geometric data types). - - This function assumes a valid connection to the MySQL server has been - established already." - (loop with sql = (format nil - (sql "/mysql/get-column-list.sql") - dbname table-name) - for (name type) in (mysql-query sql :result-type 'list) - collect (get-column-sql-expression name type))) + need to process them on the SQL side (geometric data types)." + (loop :for field :in (fields copy) + :collect (get-column-sql-expression (mysql-column-name field) + (mysql-column-dtype field)))) (declaim (inline fix-nulls)) diff --git a/src/sources/mysql/mysql.lisp b/src/sources/mysql/mysql.lisp index 6d7b7e0..3a35a03 100644 --- a/src/sources/mysql/mysql.lisp +++ b/src/sources/mysql/mysql.lisp @@ -119,7 +119,7 @@ (when qmynd:*mysql-encoding* (log-message :notice "Force encoding to ~a for ~a" qmynd:*mysql-encoding* table-name)) - (let* ((cols (get-column-list (db-name (source-db mysql)) table-name)) + (let* ((cols (get-column-list mysql)) (sql (format nil "SELECT ~{~a~^, ~} FROM `~a`" cols table-name))) (if (range-list mysql) diff --git a/src/sources/mysql/sql/get-column-list.sql b/src/sources/mysql/sql/get-column-list.sql deleted file mode 100644 index 8de5952..0000000 --- a/src/sources/mysql/sql/get-column-list.sql +++ /dev/null @@ -1,6 +0,0 @@ --- params: dbname --- table-name - select column_name, data_type - from information_schema.columns - where table_schema = '~a' and table_name = '~a' -order by ordinal_position;