Skip to content

perf: make comparison computation slightly faster#232

Merged
hf-kklein merged 5 commits intomainfrom
more-pef
Dec 16, 2025
Merged

perf: make comparison computation slightly faster#232
hf-kklein merged 5 commits intomainfrom
more-pef

Conversation

@hf-kklein
Copy link
Copy Markdown
Contributor

No description provided.

@hf-kklein hf-kklein requested a review from Copilot December 16, 2025 16:42
Base automatically changed from fmtsql to main December 16, 2025 16:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR optimizes the SQL view v_ahb_diff to improve comparison computation performance by refactoring redundant condition checks and improving the query structure.

  • Replaced CROSS JOIN with JOIN to eliminate unnecessary cross products and leverage join optimization
  • Introduced a modified_check CTE to compute changed_columns once instead of repeating comparison logic multiple times
  • Changed from IFNULL(col, '') != IFNULL(col, '') to IS NOT for NULL-safe comparisons, which is more efficient

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

-- Pre-compute changed_columns once, derive diff_status from it
modified_check AS (SELECT TRIM(
CASE
WHEN old_tbl.line_ahb_status IS NOT new_tbl.line_ahb_status
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comparison uses IS NOT instead of IS DISTINCT FROM. In SQL, IS NOT is used for boolean negation, not for inequality comparison. For NULL-safe inequality, use IS DISTINCT FROM (or in SQLite, the pattern old_tbl.line_ahb_status IS NOT new_tbl.line_ahb_status is invalid syntax). The correct approach is either old_tbl.line_ahb_status != new_tbl.line_ahb_status OR (old_tbl.line_ahb_status IS NULL) != (new_tbl.line_ahb_status IS NULL) or if the SQL dialect supports it, old_tbl.line_ahb_status IS DISTINCT FROM new_tbl.line_ahb_status.

Copilot uses AI. Check for mistakes.
THEN 'line_ahb_status, '
ELSE '' END ||
CASE
WHEN old_tbl.bedingung IS NOT new_tbl.bedingung
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comparison uses IS NOT instead of a proper NULL-safe inequality operator. This is invalid SQL syntax. Use IS DISTINCT FROM if supported by your SQL dialect, or the explicit pattern old_tbl.bedingung != new_tbl.bedingung OR (old_tbl.bedingung IS NULL) != (new_tbl.bedingung IS NULL).

Copilot uses AI. Check for mistakes.
THEN 'bedingung, '
ELSE '' END ||
CASE
WHEN old_tbl.line_name IS NOT new_tbl.line_name
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comparison uses IS NOT instead of a proper NULL-safe inequality operator. This is invalid SQL syntax. Use IS DISTINCT FROM if supported by your SQL dialect, or the explicit pattern old_tbl.line_name != new_tbl.line_name OR (old_tbl.line_name IS NULL) != (new_tbl.line_name IS NULL).

Copilot uses AI. Check for mistakes.
Konstantin and others added 3 commits December 16, 2025 17:43
Add comment explaining that SQLite's "IS NOT" operator is equivalent to
SQL standard "IS DISTINCT FROM" for NULL-safe comparisons.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@hf-kklein hf-kklein merged commit 4f51fde into main Dec 16, 2025
21 checks passed
@hf-kklein hf-kklein deleted the more-pef branch December 16, 2025 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants