Mysql
 SQL >> Database >  >> RDS >> Mysql

MySQL "Operand should contain 1 column(s)" ed errori MAX_JOIN_SIZE

Inizia rimuovendo le parentesi attorno alla clausola SELECT. Secondo Microsoft TechNet, la forma corretta di un insert-select è:

INSERT INTO MyTable (PriKey, Description) SELECT ForeignKey, Description FROM SomeView

Il secondo messaggio — "The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay" — è MySQL che ti protegge, non un malfunzionamento. Con molte righe sia in BOOK sia in temp_cheques, il loro incrocio produce un set di risultati m×n che potrebbe richiedere moltissimo tempo.

Se hai davvero verificato la query ed è ciò che vuoi, alza la guardia per quella sessione ed eseguila di nuovo:

SET SQL_BIG_SELECTS = 1;

Aspettati che richieda tempo. La soluzione migliore a lungo termine è di solito aggiungere un predicato WHERE selettivo, così che l'ottimizzatore possa smettere di stimare un prodotto cartesiano.