Configure fetch size for tables (not forms)

Hello all,
I’m trying to configure the fetch size for tables in LibreOffice Base but I don’t understand how it can be done. I’ve seen how to do it for a form using a macro (here: In Base how can all records in a grid be immediately available), but this doesn’t seem to work for tables shown in a grid (the one you get when you double-click on the table name in the “Tables” list). Or if it does, I can’t figure out how to trigger the macro when the table is opened. My tables are not really big, but LibreOffice insists on loading them only partially on open, which is quite annoying: every time it needs to load more data, there is a noticeable pause, and I’d really want to avoid that, even if it means the initial loading is longer.
I’m using LibreOffice 7.2.5.1.
Any hint? Thanks!

Tables are also difficult in other ways when it comes to the respective field widths.

Workaround

Use a form. This can also be created in table form and you can use your macro. In the form you can also store the respective field width.

I’d very much prefer not using a form. Tables are difficult indeed, but they offer quite a few features I’m used to, when I’m not used to forms at all. And each time I tried to make one, I ended up pulling the little hair I have left because I couldn’t make sense of anything.
I’m actually very surprised this fetch size is not a basic preference either at database level, or at table level. Having to use a macro just to configure this seems totally crazy to me. Isn’t there any other way to configure it? Even if it’s global, I don’t care, the default is just way too low for my usage…
Thanks for the answer anyway!

What database are you working with?

PostgreSQL v7.4.8 (very old version, I know, but it’s for my work, I don’t have a choice).

I’m afraid it’s impossible without macros.

  1. Create a Module1 module in the Standard library of your .odb document and put the following macro there:
Sub ComponentOpened(oEvent)
  Dim oController, oRowSet
  oController = oEvent.Supplement.Controller
  If oController.supportsService("com.sun.star.sdb.DataSourceBrowser") Then
    oRowSet=oController.Controls(0).Model.Rowset
    oRowSet.FetchSize=300  ' any value
  End If
End Sub  
  1. Menu / Tools / Customize… Tab Events. Assign to event Loaded a sub component macro Standard.Module1.ComponentOpened.

  2. Opening (double-clicking) any table will read 300 records.

Awesome, works perfectly! Thank you so much! :+1:

1 Like