Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you want an example of a <a href="https://my.vertica.com/docs/6.1.x/HTML/index.htm#17320.htm" rel="nofollow">MERGE</a> statement follow the link. That is the link to the Vertica documentation. Remember to follow the instructions clearly. You cannot write a Merge with <code>WHEN NOT MATCHED</code> followed and <code>WHEN MATCHED</code>. It has to follow the sequence as given in the usage description in the documentation (which is the other way round). But you can choose to omit one completely. </p> <p>I'm not sure, if you are aware of the fact that in Vertica, data which is updated or deleted is not really removed from the table, but just marked as 'deleted'. This sort of data can be manually removed by running: <strong>SELECT PURGE_TABLE('schemaName.tableName');</strong> </p> <p>You might need super user permissions to do that on that schema. More about this can be read here: <a href="https://my.vertica.com/docs/6.1.x/HTML/index.htm#9903.htm" rel="nofollow" title="Vertica documentation: Purge Data">Vertica Documentation; Purge Data</a>. An example of this from Vertica's Website: <a href="http://www.vertica.com/2012/08/27/load-new-data-and-modify-data-simultaneously/" rel="nofollow" title="Update and Insert Simultaneously using MERGE">Update and Insert Simultaneously using MERGE</a></p> <p>I agree that Merge is supported in Vertica version 6.0. But if Vertica's AHM or epoch management settings are set to save a lot of history (deleted) data, it will slow down your updates. The update speeds might go from what is bad, to worse, to horrible. </p> <p>What I generally do to get rid of deleted (old) data is run the purge on the table after updating the table. This has helped maintain the speed of the updates. Merge is useful where you definitely need to run updates. Especially incremental daily updates which might update millions of rows. </p> <p>Getting to your answer: I don't think Vertica supportes Subquery in Merge. You would get the following.</p> <pre><code>ERROR 0: Subquery in MERGE is not supported </code></pre> <p>When I had a similar use-case, I created a view using the sub-query and merged into the destination table using the newly created view as my source table. That should let you keep using MERGE operations in Vertica and regular PURGEs should let you keep your updates fast. </p> <p>In fact merge also helps avoid duplicate entries during inserts or updates if you use the correct combination of fields in ON clause, which should ideally be a join on the primary keys. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload