This is an automated email from the ASF dual-hosted git repository.

gstein pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/steve.git

commit 73065966b305333f751a34ea15a8e655d38e892d
Author: Greg Stein <[email protected]>
AuthorDate: Fri Sep 26 14:09:25 2025 -0500

    add an alternative query
---
 v3/queries.yaml | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/v3/queries.yaml b/v3/queries.yaml
index 470fc81..4cc3548 100644
--- a/v3/queries.yaml
+++ b/v3/queries.yaml
@@ -64,17 +64,27 @@ election:
         SELECT 1 FROM vote
         WHERE vote_token = ?
         LIMIT 1
-    q_recent_vote: |
-        SELECT ciphertext FROM vote
-        WHERE vote_token = ?
-        ORDER BY _ROWID_ DESC
-        LIMIT 1
     q_all_issues: |
         SELECT m._ROWID_
         FROM mayvote m
         JOIN issue i ON m.iid = i.iid
         WHERE i.eid = ?
 
+    q_recent_vote: |
+        SELECT ciphertext FROM vote
+        WHERE vote_token = ?
+        ORDER BY _ROWID_ DESC
+        LIMIT 1
+    # ALTERNATIVE to above:
+    #
+    # SELECT ciphertext FROM vote
+    # WHERE vote_token = ?
+    # AND vid = (SELECT MAX(vid) FROM vote WHERE vote_token = ?)
+    #
+    # ... this is clearer about the MAX() and avoids the sorting from
+    #     the ORDER BY. However, with few revotes, that sort is not
+    #     expensive. Collect some data. Or maybe people can lobby.
+
 
 person:
     c_add_person: |

Reply via email to