()
| 635 | |
| 636 | #[test] |
| 637 | fn test_query_optimization() { |
| 638 | let fixture = TestFixture::new().expect("Failed to create test fixture"); |
| 639 | // Setup fresh graph for this test to avoid interference |
| 640 | fixture |
| 641 | .setup_graph("test_query_optimization") |
| 642 | .expect("Failed to setup graph"); |
| 643 | // Re-insert fraud data since we have a fresh graph |
| 644 | fixture |
| 645 | .insert_fraud_data() |
| 646 | .expect("Failed to insert fraud data"); |
| 647 | |
| 648 | // Test that selective filters are applied early |
| 649 | let start = std::time::Instant::now(); |
| 650 | |
| 651 | fixture.assert_query_succeeds( |
| 652 | "MATCH (a:Account)-[t:Transaction]->(m:Merchant) |
| 653 | WHERE a.id = '4000001000' // Very selective |
| 654 | AND t.amount > 1000 |
| 655 | RETURN count(*) as result_count", |
| 656 | ); |
| 657 | |
| 658 | let selective_duration = start.elapsed(); |
| 659 | |
| 660 | // Compare with less selective query |
| 661 | let start = std::time::Instant::now(); |
| 662 | |
| 663 | fixture.assert_query_succeeds( |
| 664 | "MATCH (a:Account)-[t:Transaction]->(m:Merchant) |
| 665 | WHERE t.amount > 1000 // Less selective |
| 666 | AND a.id = '4000001000' |
| 667 | RETURN count(*) as result_count", |
| 668 | ); |
| 669 | |
| 670 | let less_selective_duration = start.elapsed(); |
| 671 | |
| 672 | // Both should complete quickly, but selective might be faster |
| 673 | assert!( |
| 674 | selective_duration.as_secs() < 5, |
| 675 | "Selective query should be fast" |
| 676 | ); |
| 677 | assert!( |
| 678 | less_selective_duration.as_secs() < 5, |
| 679 | "Less selective query should still be reasonable" |
| 680 | ); |
| 681 | } |
nothing calls this directly
no test coverage detected