Bulk photo uploads now complete reliably under high load

Fixed database connection pool saturation that caused bulk photo uploads to fail.

Bug Fixes

Bulk uploads of 700+ photos intermittently failed at confirmation due to database connection pool saturation — each photo confirmation held a connection through multiple steps, including an expensive sort-order lookup. We've refactored to release connections between queries and added an index for faster lookups. Bulk uploads now complete cleanly under burst load. Transient storage failures are also retried automatically.