Похожие чаты

I also have 2 other questions. Tl;dr, I have an

app that communicates with an SQL DB and the queries are quite slow, I'm trying to speed up the process because it's a mobile app.

1)
I made a data-type for the database entries:
public readonly struct DatabaseEntry
{
public readonly int Id;
public readonly DateTime Date;
public readonly TimeSpan OraIncepere;
public readonly TimeSpan OraFinal;
public readonly TimeSpan CursAlocat;
public readonly TimeSpan PregatireAlocat;
public readonly TimeSpan RecuperareAlocat;
public readonly TimeSpan Total;
public readonly string Observatii;
}

Should this be a class or a struct from an efficiency point of view?

2)
Are things in the connection string like:
Asynchronous Processing=true;Pooling=True;Min Pool Size=3;Max Pool Size=100;
relevant?

11 ответов

11 просмотров

your mobile app is connected directly to the db?

Kuran-Kaname Автор вопроса
ƒabio
your mobile app is connected directly to the db?

Yes. I know it's not a good practice and I should do http requests but I don't have the time right now to do that logic

Kuran Kaname
Yes. I know it's not a good practice and I should ...

Np my question is just to understand, i dont think you will speed up application in that way.. where it is slow? when pushing queries? maybe the connection is disposed and reopened every time. are you using async pattern?

From an effeciency point of view, structs are faster to create and destroy, but not to copy. Anyway I really wouldn't care that much and I'd rather use classes/structs for they're main difference: structs are a value-type while classes are references

Kuran-Kaname Автор вопроса
ƒabio
Np my question is just to understand, i dont think...

I'm doing an initial query to get all the elements from the DB and add them to a local list like: private async Task RefreshElementsAsync() => Entries = await _sql.GetAllElementsAsync().ConfigureAwait(false); —————————————— public async Task<List<DatabaseEntry>> GetAllElementsAsync() { IEnumerable<DatabaseEntry> result; await using (var conn = new SqlConnection(Secrets.ConnStr)) { result = await conn.QueryAsync<DatabaseEntry>($@"SELECT * FROM ""prezenta.{User}"""); } var elements = result.ToList(); return elements; } Using dapper btw

Kuran-Kaname Автор вопроса
Kuran Kaname
I'm doing an initial query to get all the elements...

The only solution I can think of is caching the entries in a json and reading them. I did this for the user accounts because it would take a long time to query if the account entered is correct . I cache them when the app first starts in a json file and read them from it

Kuran Kaname
I'm doing an initial query to get all the elements...

so the problem is only here? slow to get initial data?

Kuran-Kaname Автор вопроса
ƒabio
so the problem is only here? slow to get initial d...

Yes. Adding or deleting entries is quite instant

Kuran Kaname
Yes. Adding or deleting entries is quite instant

var elements = result.ToList(); to ToListAsync

Kuran-Kaname Автор вопроса
ƒabio
var elements = result.ToList(); to ToListAsync

Oh I had no idea that existed lol Adding it, thanks

Kuran Kaname
Oh I had no idea that existed lol Adding it, thank...

if QueryAsync retrieve the data, use ToList is ok, otherwise use tolistasync

Похожие вопросы

Обсуждают сегодня

а через ESC-код ?
Alexey Kulakov
29
30500 за редактор? )
Владимир
47
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
Чёт не понял, я ж правильной функцией воспользовался чтобы вывести отладочную информацию? но что-то она не ловится
notme
18
Привет)) уже кажется эту тему перемусолили, но вот я так и не понял. Я сейчас сижу на 27дюймов 2к мониторе. На Актуальной макоси, если я куплю 27д 4к монитор: - будет ли изобр...
Vladislav Piskunov
15
Hi guys, any problem with Pulsebrige? Trying to transfer from wETH to ETH. First it tells me to connect my metamask "through mobile app" not desktop. Then I did and confirmed ...
Snowflakecrypto
13
any reference of this implementation?
BitBuddha
29
У меня есть функция где происходит это: write_bit(buffer, 1); write_bit(buffer, 0); write_bit(buffer, 1); write_bit(buffer, 1); write_bit(buffer, 1); w...
~
13
Страшнейшая правда про списки ЦБ. С первых дней жизни P2P сферы, молодые человеки, начитавшись законодательной базы и "внутренних" документов, решили, что им противостоит сер...
Foxcool
3
&"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.42.34433\bin\Hostx64\x64\dumpbin.exe" /EXPORTS C:\Users\Yeet\Tauon\vcpkg\installed\x64-window...
Martin Rys
6
Карта сайта