Details

    • Type: Task
    • Status: Closed
    • Priority: Minor
    • Resolution: Not a Bug
    • Fix Version/s: N/A
    • Component/s: OTHER
    • Labels:
      None

      Description

      When trying queries in the interactive client I frequently add limit 25 (or have to hit Ctrl-C).
      Would it be possible to have a setting to automatically add the limit clause on relevant queries?
      Or perhaps it's better to execute the entire query but only display the top 25 rows.

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            serg Sergei Golubchik added a comment -

            Did you try setting @@sql_select_limit variable?

            If you want to execute the entire query but only display top 25 rows, you can set the pager as

            MariaDB [test]> \P head -n 15
            PAGER set to 'head -n 15'
            MariaDB [test]> show status;
            +-----------------------------------------------+-------------+
            | Variable_name                                 | Value       |
            +-----------------------------------------------+-------------+
            | Aborted_clients                               | 0           |
            | Aborted_connects                              | 0           |
            | Access_denied_errors                          | 0           |
            | Aria_pagecache_blocks_not_flushed             | 0           |
            | Aria_pagecache_blocks_unused                  | 15706       |
            | Aria_pagecache_blocks_used                    | 0           |
            | Aria_pagecache_read_requests                  | 0           |
            | Aria_pagecache_reads                          | 0           |
            | Aria_pagecache_write_requests                 | 0           |
            | Aria_pagecache_writes                         | 0           |
            | Aria_transaction_log_syncs                    | 0           |
            | Binlog_commits                                | 0           |
            347 rows in set (0.01 sec)
            MariaDB [test]>
            
            Show
            serg Sergei Golubchik added a comment - Did you try setting @@sql_select_limit variable? If you want to execute the entire query but only display top 25 rows, you can set the pager as MariaDB [test]> \P head -n 15 PAGER set to 'head -n 15' MariaDB [test]> show status; +-----------------------------------------------+-------------+ | Variable_name | Value | +-----------------------------------------------+-------------+ | Aborted_clients | 0 | | Aborted_connects | 0 | | Access_denied_errors | 0 | | Aria_pagecache_blocks_not_flushed | 0 | | Aria_pagecache_blocks_unused | 15706 | | Aria_pagecache_blocks_used | 0 | | Aria_pagecache_read_requests | 0 | | Aria_pagecache_reads | 0 | | Aria_pagecache_write_requests | 0 | | Aria_pagecache_writes | 0 | | Aria_transaction_log_syncs | 0 | | Binlog_commits | 0 | 347 rows in set (0.01 sec) MariaDB [test]>
            Hide
            XTF Olaf van der Spek added a comment -

            No, I didn't, thx for the hint.
            Is there a way to auto-set it for interactive sessions?

            Show
            XTF Olaf van der Spek added a comment - No, I didn't, thx for the hint. Is there a way to auto-set it for interactive sessions?
            Hide
            serg Sergei Golubchik added a comment -

            I cannot think of any SQL way to check whether a session is interactive or not, so no SQL init-script would do.

            Perhaps the easiest way would be something like

            shell$ alias mysqli='mysql --init-command="set sql_select_limit=25;"'
            
            Show
            serg Sergei Golubchik added a comment - I cannot think of any SQL way to check whether a session is interactive or not, so no SQL init-script would do. Perhaps the easiest way would be something like shell$ alias mysqli='mysql --init-command="set sql_select_limit=25;"'

              People

              • Assignee:
                Unassigned
                Reporter:
                XTF Olaf van der Spek
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: