Open
Description
I’m using SQLite for a prepared database, but I’m encountering an issue where querying even 70 rows of data takes about 4 minutes.
here is my code for querying the database
`
export const getNouns = async query => {
var nouns = [];
var message = '';
console.log('Query home:' + new Date(), query);
await db.transaction(
tx => {
console.log('Query home trans:' + new Date(), query);
tx.executeSql(
query,
[],
(tx, results) => {
console.log('Query home result:' + new Date(), results);
for (let i = 0; i < results.rows.length; ++i) {
nouns.push(results.rows.item(i));
}
return nouns;
},
error => {
console.log('error while executing the query: Execute: ', error);
message = `error while executing the query: Execute: ${error}`;
},
);
},
error => {
console.log('error while executing the query: Transaction:', error);
message = `error while executing the query: Execute: ${error}`;
},
);
return nouns;
};
here is how i call the function to get the data
` const MainHome = () => {
var nouns = [];
useEffect(() => {
async function fetchData() {
nouns = await getNouns('SELECT Id, Text, User, CreatedAt FROM Messages');
}
fetchData();
});
console.log(`Messages Home page:` + new Date(), nouns);
return (
<View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
<Text>Main Home Screen </Text>
{nouns.map(item => {
return (
<View key={item.Id}>
<Text> {item.User}</Text>
</View>
);
})}
</View>
);
};
here is the screenshot of the time taken to call the function and process it
I was wondering if there is any way to quickly process the data?
Metadata
Metadata
Assignees
Labels
No labels