Defining a table with a sorted column
Is it possible to define a table such that the server maintains the table sorted with each new row? I'm dealing with observations on market data, and while market data for a specific stock symbol will be sorted, I will be adding multiple symbols to the same table in chunks, so that each symbol is contained within its own load file, and is sorted within that file. How can I enforce this constraint? - Luis ________________________________ IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.
Hai Luis, The relational model doesn’t have the notion of order, so there is no straightforward way to enforce this constraint. So, for instance, the standard spec. for ORDER BY is that it is merely a make-up for the output. Can you share with us why you need to / want to enforce the order of the data? Does it affect the query results in any way? If a column is known to be sorted, MonetDB will try to make use of that knowledge to speed up query executions. So, if you’re sure your column is sorted, I think you can enforce MonetDB to compute this property using the ANALYZE statement: https://www.monetdb.org/Documentation/Cookbooks/SQLrecipes/statistics. But this may not be feasible if your data is big and updates are frequent. Alternatively, maybe you can use an additional primary key / sequence column to enforce the order? Best, Jennie
On 30 Aug 2017, at 03:21, Cota, Luis
wrote: Is it possible to define a table such that the server maintains the table sorted with each new row?
I’m dealing with observations on market data, and while market data for a specific stock symbol will be sorted, I will be adding multiple symbols to the same table in chunks, so that each symbol is contained within its own load file, and is sorted within that file.
How can I enforce this constraint?
- Luis
IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses. _______________________________________________ users-list mailing list users-list@monetdb.org https://www.monetdb.org/mailman/listinfo/users-list
participants (2)
-
Cota, Luis
-
Ying Zhang