You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Speed up Dirichlet character searches using mathematical relations (LMFDB#6733, LMFDB#6422)
With the new indexes, remaining production timeouts come from an indexed
column combined with a sparse boolean filter, e.g. conductor=17 &
is_primitive=yes walks all 230K conductor-17 rows to find the 4
primitive ones (>180s on devmirror). Since a character is primitive if
and only if its conductor equals its modulus, mirror conductor/modulus
constraints when is_primitive=yes so the query is answered from the
(conductor, modulus, orbit) index (45ms). Searches for characters
induced by psi now inherit psi's order, parity and realness, and
searches that are provably empty (odd order with odd parity, is_real
with order > 2, conductor not dividing modulus, etc.) short-circuit
with an explanatory message instead of scanning the table.
Verified with EXPLAIN ANALYZE on devmirror and new tests in
lmfdb/characters/test_characters.py (3 passed); pyflakes clean.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
# Mathematical facts relating the search columns let us short-circuit
336
+
# or speed up several searches that postgres would otherwise answer by
337
+
# filtering a large part of the table (issues #6733 and #6422).
338
+
con=forced_int(query.get("conductor"))
339
+
mod=forced_int(query.get("modulus"))
340
+
ifconisnotNoneandmodisnotNone:
341
+
ifcon>0andmod%con!=0:
342
+
returnforce_no_results(info, query, "the conductor of a character divides its modulus, so there are no characters of modulus %s and conductor %s", mod, con)
343
+
ifquery.get("is_primitive") isFalseandcon==mod:
344
+
returnforce_no_results(info, query, "an imprimitive character has conductor strictly smaller than its modulus")
345
+
ifquery.get("is_primitive") isTrue:
346
+
ifrefine_primitive_search(info, query):
347
+
return
348
+
if"order"inquery:
349
+
olo, ohi=int_bounds(query["order"])
350
+
is_real=query.get("is_real")
351
+
ifis_realisTrueandoloisnotNoneandolo>2:
352
+
returnforce_no_results(info, query, "a real character has order at most 2")
353
+
ifis_realisFalseandohiisnotNoneandohi<=2:
354
+
returnforce_no_results(info, query, "every character of order at most 2 is real")
355
+
if (is_realisTrueandohiisnotNoneandohi<=2) or (is_realisFalseandoloisnotNoneandolo>2):
356
+
# the order constraint already forces the requested realness
357
+
delquery["is_real"]
358
+
oforced=forced_int(query["order"])
359
+
ifoforcedisnotNoneandoforced%2==1:
360
+
# a character of odd order takes the value 1 at -1
361
+
ifquery.get("is_even") isFalse:
362
+
returnforce_no_results(info, query, "a character of odd order is even, so there are no odd characters of order %s", oforced)
0 commit comments