Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!uwm.edu!linac!att!pacbell.com!lll-winken!sirius.llnl.gov From: manatt@sirius.llnl.gov (Doug Manatt) Newsgroups: comp.databases Subject: Re: Optimal SQL query needed Keywords: SQL supersede timestamps Message-ID: <93266@lll-winken.LLNL.GOV> Date: 15 Mar 91 23:19:41 GMT Sender: usenet@lll-winken.LLNL.GOV Organization: Lawrence Livermore National Labs, Livermore CA Lines: 30 Nntp-Posting-Host: sirius.llnl.gov In article <13659@blia.sharebase.com>, miket@blia.sharebase.com (Mike Tossy) writes: >In article <1991Mar13.224746.5293@qualcomm.com>, greg@harvey.qualcomm.com (greg Noel) writes: >> ... >>Intuitivly, what I would like to tell >>the data base engine is to look up all records with the same value of A riffle >> through them, and select the one with the largest B.C value. >>... >> Is there a way to do do the query more optimally or to do the whole query in >> one request, so that the execptions don't need to be handled by the program? >... >I suggest that the solution is to add another column B'. Column B is the >time the record became active and B' is the time the record became inactive The quick and cheap solution is to add a 1 byte boolean column that tells only if the record is currently valid or invalid. In our design, many of our timestamped entries have a supercede column that takes on the two values ("T" or "F") and when an existing entry is updated all "F"s are changed to "T"s before the insert. Doug Manatt Lawrence Livermore Natl Lab Human -- (415) 422-7257 FAX -- (415) 422-3160 manatt@lll-winken.llnl.gov -- Doug Manatt Lawrence Livermore Natl Lab Human -- (415) 422-7257 FAX -- (415) 422-3160 manatt@lll-winken.llnl.gov